A00-231
Free A00-231 practice questions
10 questions from our A00-231 practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.
Question 1 of 10, Access and Create Data Structures
A comma-delimited file contains the line 101,"Smith, Ann",,45. The programmer wants SAS to keep "Smith, Ann" as one value without quotation marks and to read the empty field between the two consecutive commas as a missing value. Which INFILE option should be added?
- ADSD Correct answer
- BTRUNCOVER
- CMISSOVER
- DDLM=','
Answer and explanation: DSD treats consecutive delimiters as a missing value, removes quotation marks from quoted values, ignores delimiters inside quotes, and uses a comma as the default delimiter. DLM=',' alone treats consecutive commas as a single delimiter and splits the quoted name. MISSOVER and TRUNCOVER control what happens when a record is shorter than the INPUT statement expects; they do not handle quotes or empty fields.
Question 2 of 10, Access and Create Data Structures
PROC IMPORT reads a CSV file in which some city names after row 500 are longer than any earlier value, and those names are truncated in the output data set. Which statement in the PROC IMPORT step prevents this?
- Adatarow=1;
- Bgetnames=no;
- Creplace;
- Dguessingrows=max; Correct answer
Answer and explanation: PROC IMPORT sets column types and lengths from a sample of rows (20 by default), so values longer than anything in the sample are truncated; GUESSINGROWS=MAX scans every row before setting lengths. GETNAMES=NO reads the header row as data, DATAROW=1 also starts reading at the header line, and REPLACE only allows an existing output data set to be overwritten.
Question 3 of 10, Manage Data
A programmer wants to keep only the first order for each customer_id in work.orders and save the removed orders in a separate data set. Which step does this?
- Aproc sort data=orders out=first nodupkey dupout=extra; by customer_id; run; Correct answer
- Bproc sort data=orders out=first nodupkey; by _all_; run;
- Cproc sort data=orders out=first dupout=extra; by customer_id _all_; run;
- Dproc sort data=orders out=first noduprecs dupout=extra; by customer_id; run;
Answer and explanation: NODUPKEY keeps only the first observation for each unique BY value, and DUPOUT= writes the removed observations to another data set. NODUPRECS removes only observations that are identical in every variable to the previous one, DUPOUT= has no effect without NODUPKEY or NODUPRECS, and BY _ALL_ with NODUPKEY removes only complete duplicates instead of extra orders per customer.
Question 4 of 10, Manage Data
Consider this step. What are the value and the length of yr? data codes; code = 'AB-2026-XY'; yr = substr(code, 4, 4); run;
- A2026 with a length of 4
- B2026 with a length of 200
- C2026 with a length of 10 Correct answer
- D-202 with a length of 4
Answer and explanation: SUBSTR starting at position 4 for 4 characters returns 2026, and a new variable created by SUBSTR gets the length of the source variable, which is 10 here because code was assigned a 10-character literal. A length of 4 would require a LENGTH statement, -202 would start at position 3, and 200 is the default length for functions such as SCAN and CATX, not SUBSTR.
Question 5 of 10, Manage Data
The variable phone contains values such as (555) 123-4567 ext. 9. Which function call returns only the digits, 55512345679?
- Acompress(phone, 'ext. ')
- Bcompress(phone, , 'd')
- Ccompress(phone, , 'kd') Correct answer
- Dcompress(phone, '()- ')
Answer and explanation: The third argument of COMPRESS lists modifiers; k means keep instead of remove, and d means digits, so 'kd' keeps only digits. Removing parentheses, hyphens, and blanks still leaves the letters and period of ext., the d modifier alone removes the digits, and removing the characters e, x, t, the period, and the blank still leaves the parentheses and the hyphen.
Question 6 of 10, Manage Data
Which WHERE statement selects observations where code is exactly four characters long and begins with A, such as A1B2?
- Awhere code like 'A___'; with three underscores Correct answer
- Bwhere code like 'A%'; with one percent sign after the A
- Cwhere code =: 'A'; using the prefix comparison operator
- Dwhere code contains 'A___'; with three underscores
Answer and explanation: The underscore in a LIKE pattern matches exactly one character, so 'A___' matches A followed by exactly three characters (trailing blanks are ignored). The percent sign matches any number of characters, so 'A%' also matches codes of any other length, CONTAINS treats the underscores as literal characters, and the =: operator matches every code that starts with A regardless of length.
Question 7 of 10, Error Handling
This step stops with the error "Variable bonus is not on file WORK.STAFF". What change produces the intended subset? data highpay; set work.staff; bonus = salary * 0.1; where bonus > 5000; run;
- AAdd bonus to a KEEP= data set option on SET
- BAdd a RETAIN statement for bonus before SET
- CReplace the WHERE statement with if bonus > 5000; Correct answer
- DMove the WHERE statement above the SET statement
Answer and explanation: A WHERE statement filters observations as they are read, so it can only reference variables that exist in the input data set, and bonus is created later in the step. A subsetting IF is evaluated during execution after the assignment, so it can use the new variable. Moving WHERE has no effect because it is not executable, KEEP= cannot keep a variable that is not in the input, and RETAIN does not add bonus to the input data.
Question 8 of 10, Error Handling
work.orders contains price and qty but no total. Why does this step create a data set with 0 observations? data big; set work.orders; if total > 100; total = price * qty; run;
- AThe assignment must come before SET for total to exist in the PDV
- BThe step needs a KEEP statement for total before the IF statement
- CThe subsetting IF cannot reference a variable created in the same step
- Dtotal is missing when the IF statement runs, so every observation is deleted Correct answer
Answer and explanation: Statements execute in order, and total is reset to missing at the start of each iteration, so it is missing when the subsetting IF tests it; missing is not greater than 100 and every observation is deleted. Moving the assignment above the IF fixes the logic. A subsetting IF can use new variables when they are assigned first, and neither moving the assignment above SET nor adding KEEP helps.
Question 9 of 10, Generate Reports and Output
A report must show column labels instead of variable names and must not show the Obs column. Which PROC PRINT statement does this?
- Aproc print data=work.emp label noobs; Correct answer
- Bproc print data=work.emp labels obs=0;
- Cproc print data=work.emp split noobs;
- Dproc print data=work.emp nolabel id;
Answer and explanation: PROC PRINT uses variable labels as column headings only when LABEL (or SPLIT=) is specified, and NOOBS suppresses the Obs column. SPLIT needs a split character such as SPLIT='*', OBS=0 prints no observations at all, and NOLABEL with ID neither turns on labels nor removes the Obs column, because ID is a separate statement rather than a PROC PRINT option.
Question 10 of 10, Generate Reports and Output
An ODS EXCEL report must put the output on a worksheet named Summary. Which statement does this?
- Aods excel file='/rpt/r.xlsx' style=Summary;
- Bods excel file='/rpt/r.xlsx' title='Summary';
- Cods excel file='/rpt/r.xlsx' options(sheet_name='Summary'); Correct answer
- Dods excel file='/rpt/r.xlsx' sheet='Summary' sheet_interval='none';
Answer and explanation: ODS EXCEL takes destination-specific suboptions in OPTIONS( ), and SHEET_NAME= names the worksheet. SHEET= is a PROC IMPORT and PROC EXPORT statement rather than an ODS option, and SHEET_INTERVAL= is only valid inside OPTIONS( ), STYLE= selects a style template, and TITLE= sets document properties rather than the sheet name.