A financial analyst is tasked with calculating cumulative quarterly sales for multiple regions from a dataset named `WORK.SALES`, sorted by `Region` and `SaleDate`. The analyst needs to reset the cumulative total for each new region. Which of the following DATA step code snippets correctly implements this logic?
Q2
A junior programmer executes a DATA step to calculate a new variable, `Ratio`, by dividing `ValueA` by `ValueB`. The SAS log shows no errors or warnings, but a subsequent `PROC MEANS` reveals that the mean of `Ratio` is much lower than expected. Upon manual inspection, the programmer finds that `ValueB` is sometimes zero. How does the SAS DATA step handle division by zero by default, and what message should the programmer have looked for in the log?
Q3Multiple answers
A marketing dataset contains a `CampaignID` field with values like 'FY24-Q3-EMAIL-PROMO123'. A data analyst needs to extract the fiscal year, the quarter, and the campaign type ('EMAIL') into separate variables. Which of the following SAS functions are required to accomplish this task? (Select THREE)
Q4
True or False: When merging two SAS datasets using a `MERGE` statement with a `BY` statement, SAS requires both datasets to be sorted by the `BY` variables. If they are not sorted, SAS will stop with an error and halt program execution.
Q5
A data scientist is using `PROC IMPORT` to read a large CSV file (`'c:\data\survey.csv'`) where the first 50 rows contain metadata and notes, with the actual column headers in row 51. Which combination of options in the `PROC IMPORT` statement is required to correctly read the data, starting from the headers in row 51?
Q6
A reporting analyst at a retail company needs to generate a weekly sales report. The requirements are as follows: 1. The final report must be an Excel file named `weekly_sales.xlsx` for business users. 2. A PDF version named `archive_sales.pdf` must be created for archival purposes. 3. The report should contain summary statistics from `PROC MEANS` and frequency tables from `PROC FREQ`. 4. However, the archived PDF should NOT contain the detailed frequency tables from `PROC FREQ` to save space. Which ODS code block correctly fulfills all these requirements?
Q7
A dataset named `PATIENT_METRICS` is in a 'wide' format, with one row per patient and separate columns for measurements taken on different dates (`Weight_Day1`, `Weight_Day7`, `Weight_Day30`). To perform a time-series analysis, the data needs to be restructured into a 'long' format with columns `PatientID`, `Day`, and `Weight`. Which `PROC TRANSPOSE` step correctly performs this transformation?
Q8
You need to assign a permanent library reference named `PROJECT1` to a directory located at `/user/data/project1`. The data in this directory is a mix of SAS datasets and Microsoft Excel files. You want to use the `XLSX` engine to directly read the Excel files. Which `LIBNAME` statement is syntactically correct for this purpose?
Q9
A developer is writing a program to categorize customers into one of four distinct, non-overlapping tiers based on their `TotalSpending`. Which conditional logic structure is generally more efficient and readable for this task compared to a series of `IF-THEN/ELSE IF` statements?
Q10
A hospital administrator wants to create a report that groups patient satisfaction scores (`Score`, ranging 1-100) into descriptive categories: 'Poor' (1-40), 'Average' (41-70), 'Good' (71-90), and 'Excellent' (91-100). Any other score should be labeled 'Invalid'. Which `PROC FORMAT` code correctly defines this custom format?