A00-231 Sample Questions & Answers
Manipulating and managing SAS data takes well over a third of the weight, including date values and sorting, next to creating data sets and reaching outside libraries, spotting and resolving coding mistakes, and producing list and summary reports.
Launch the full A00-231 simulator →Showing 10 of 20 free samples.
- Question 1Advanced
Generate Reports and Output · Generate Output with ODS
A reporting analyst at a retail company needs to generate a weekly sales report. The requirements are as follows:
- The final report must be an Excel file named
weekly_sales.xlsxfor business users. - A PDF version named
archive_sales.pdfmust be created for archival purposes. - The report should contain summary statistics from
PROC MEANSand frequency tables fromPROC FREQ. - However, the archived PDF should NOT contain the detailed frequency tables from
PROC FREQto save space.
Which ODS code block correctly fulfills all these requirements?
Show answer & explanation
Correct answer: D
This is the correct solution. It opens both ODS destinations (EXCEL and PDF) at the beginning. It then uses
ods pdf exclude Freq;to specifically tell the PDF destination to ignore any output fromPROC FREQ. The EXCEL destination is not affected and will receive output from both procedures. Finally,ods _all_ close;is the best practice to close all open destinations. This approach is targeted and correctly implements the specific exclusion requirement for only one of the destinations. - The final report must be an Excel file named
- Question 2Advanced
Manage Data · Restructure Data with PROC TRANSPOSE
A dataset named
PATIENT_METRICSis 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 columnsPatientID,Day, andWeight. WhichPROC TRANSPOSEstep correctly performs this transformation?Show answer & explanation
Correct answer: C
This is the most efficient and correct solution. The
BY PatientID;statement ensures each patient's data is processed as a group andPatientIDis retained in the output. TheVAR Weight_:;statement uses a variable list to select all variables starting with 'Weight_', which is a flexible way to include all measurement columns. By default,PROC TRANSPOSEwill create a_NAME_variable with the original variable names (Weight_Day1, etc.) and aCOL1variable with their values. TheRENAME=option is then used to give these new columns more meaningful names. Subsequent data steps would be needed to parse the day number from theMeasurementvariable. - Question 3Intermediate
Access and Create Data Structures · Investigate SAS Data Libraries
You need to assign a permanent library reference named
PROJECT1to 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 theXLSXengine to directly read the Excel files. WhichLIBNAMEstatement is syntactically correct for this purpose?Show answer & explanation
Correct answer: B
The correct syntax for a LIBNAME statement is
LIBNAME libref [engine] 'path' [options];. The engine name,XLSXin this case, is specified directly after the libref and before the path. TheENGINE=keyword is not used in this context. - Question 4Beginner
Manage Data · Conditionally Execute Statements
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 ofIF-THEN/ELSE IFstatements?Show answer & explanation
Correct answer: C
For evaluating a single variable against multiple mutually exclusive conditions, a
SELECTgroup is often more efficient and easier to read than a long chain ofIF-THEN/ELSE IFstatements. TheSELECTstatement evaluates the expression once and then compares the result to eachWHENcondition, which can be faster than re-evaluating conditions in anIFchain. - Question 5Intermediate
Generate Reports and Output · Enhance Reports with PROC FORMAT
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'. WhichPROC FORMATcode correctly defines this custom format?Show answer & explanation
Correct answer: A
This code is correct. The
VALUEstatement defines a format namedScoreFmt. It correctly specifies numeric ranges for each category. The keywordOTHERis used as a catch-all for any values that do not fall into the specified ranges, which is the proper way to handle unexpected or invalid data. - Question 6AdvancedSelect 2
Manage Data · Use Macro Variables
A programmer is developing a reusable program that processes monthly data. The input dataset name changes each month (e.g.,
data_jan,data_feb). To make the program flexible, the programmer wants to use a macro variable&Monthto specify the dataset name. Which statements correctly create a macro variable from a DATA step variable and then use it in a subsequent DATA step? (Select TWO)Show answer & explanation
Correct answers: A, C
CALL SYMPUTXis the recommended routine for creating a macro variable from a DATA step variable's value. It automatically handles data type conversions and trims leading/trailing blanks, making it more robust thanCALL SYMPUT.To reference the value of a macro variable, you use an ampersand (
&) followed by the variable name. The macro processor will resolve&Monthto its current value (e.g., 'jan') before the SAS compiler executes the statement, resulting inset data_jan;. - Question 7Intermediate
Error Handling · Identify and Resolve Programming Logic Errors
A program designed to calculate compound interest runs without any syntax errors. However, the final interest amount is always equal to the interest from the very last period, not the accumulated total. The programmer suspects a logic error in the
DOloop. Review the code below:data WORK.COMPOUND; Principal = 1000; Rate = 0.05; do Year = 1 to 10; Interest = Principal * Rate; Principal = Principal + Interest; end; run;What is the primary logic error causing the incorrect final
Principalvalue in the output dataset?Show answer & explanation
Correct answer: C
The DATA step reads data and then has an implicit
OUTPUTat the end. In this case, there is no input dataset, so the DATA step executes its code once. TheDOloop iterates 10 times, correctly updating thePrincipalvariable in memory. However, because there is no explicitOUTPUTstatement inside the loop, SAS only writes to the output dataset once, at the very end of the DATA step. At that point,Principalholds its final calculated value, and only a single observation is created. - Question 8Advanced
Access and Create Data Structures · Combine SAS Data Sets
A clinical research organization is consolidating patient data from three sources:
DEMO: ContainsPatientIDand demographic variables (e.g.,Age,Gender). This is the master list of all patients.VISITS: ContainsPatientID,VisitDate, andVisitType. A patient can have multiple visits.LABS: ContainsPatientID,TestDate, andResult. A patient may not have lab results for every visit.
The goal is to create a final dataset,
ANALYSIS, that contains one row for each visit a patient had, including their demographic information and any lab results that match thePatientID. Which sequence of steps is the most robust and accurate method to achieve this?flowchart TD A[DEMO Data] --> C{Sort DEMO} B[VISITS Data] --> D{Sort VISITS} C & D --> E(Merge DEMO and VISITS) F[LABS Data] --> G{Sort LABS} E & G --> H(Merge with LABS) H --> I[Final ANALYSIS Dataset]Show answer & explanation
Correct answer: C
This is the correct and most robust approach. The first merge is a one-to-many merge, combining the single-record-per-patient
DEMOdata with the multiple-records-per-patientVISITSdata. This correctly propagates demographic information to each visit record. The second merge then adds the lab results. This two-step process correctly handles the different granularities (one-to-many relationships) of the source tables. Sorting before each merge is critical. - Question 9Intermediate
Manage Data · Use SAS Functions (Conversion)
A dataset contains a character variable
LoanDate_charwith values like '2024-03-15'. To perform date calculations, it must be converted to a numeric SAS date variable namedLoanDate_num. Which assignment statement correctly performs this conversion?Show answer & explanation
Correct answer: B
The
INPUT()function is used to convert character values to numeric values. The first argument is the source character variable (LoanDate_char), and the second argument is the informat that describes the structure of the character string. Theyymmdd10.informat correctly reads a date in the 'YYYY-MM-DD' format. - Question 10Beginner
Generate Reports and Output · Generate List Reports with PROC PRINT
A project manager wants a simple report from the
WORK.TASKSdataset, which containsProjectID,TaskName, andHoursSpent. The report must list all tasks for each project and provide a total ofHoursSpentfor each project. WhichPROC PRINTcode will generate this report?Show answer & explanation
Correct answer: B
This is the correct syntax. The
BY ProjectID;statement groups the report by project (assuming the data is already sorted byProjectID). TheSUM HoursSpent;statement instructsPROC PRINTto calculate and display a sum for theHoursSpentvariable at the end of eachBYgroup.
Ready for the real thing?
The full A00-231 simulator has every exam-style question, timed mode, and instant scoring.