






















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This exam evaluates SAS programming fundamentals, including data manipulation, data filtering, PROC steps, macro programming, data visualization, functions, datasets, and importing/exporting data. It covers real-world data analytics scenarios, statistical procedures, and SAS Enterprise Guide usage. Ideal for data analysts, statisticians, and professionals working in data-driven fields requiring SAS proficiency.
Typology: Exams
1 / 94
This page cannot be seen from the preview
Don't miss anything!























































































Question 1. Which SAS statement is used to assign a libref to a directory on the local file system? A) PROC LIBNAME B) LIBNAME C) DATA LIBREF; D) SET LIBNAME; Answer: B Explanation: The LIBNAME statement defines a library reference (libref) that points to a physical location, such as a folder on the local disk. Question 2. In a DATA step, which option on the SET statement tells SAS to read only observations 101-200 from a data set? A) FIRSTOBS=101 OBS= B) OBS=200 FIRSTOBS= C) POINT=101 END= D) KEEP=101- 200 Answer: A Explanation: FIRSTOBS= specifies the first observation to read, and OBS= specifies the last observation. Together they limit the range to 101-200. Question 3. Which of the following INPUT statement styles reads data that are separated by commas and treats consecutive delimiters as missing values? A) INPUT var1 $5. var2 $5.; B) INPUT var1 $ var2 $ / DLM=','; C) INPUT var1 $ var2 $ DSD; D) INPUT var1 $ var2 $ DLM=',';
Answer: C Explanation: The DSD option tells SAS to treat commas as delimiters and to treat consecutive delimiters as missing values, as well as to remove quotation marks. Question 4. What does the LENGTH statement do in a SAS DATA step? A) Determines the number of observations in a data set. B) Sets the storage length for a character variable. C) Changes the physical size of a SAS data set file. D) Assigns a format to a numeric variable. Answer: B Explanation: LENGTH defines the number of bytes allocated for a character variable (and can also set the length for numeric variables, though they are fixed at 8 bytes). Question 5. Which PROC procedure provides a detailed description of the structure, attributes, and contents of a SAS data set? A) PROC PRINT B) PROC CONTENTS C) PROC FREQ D) PROC SORT Answer: B Explanation: PROC CONTENTS lists metadata such as variable names, types, lengths, formats, and labels for a SAS data set. Question 6. Which of the following statements correctly creates a new numeric variable called age that is the difference between the current year and a birthdate variable (stored as a SAS date)? A) age = year(today()) - year(birthdate);
Question 9. Which of the following options on PROC SORT removes duplicate observations based on the BY variables? A) NODUPKEY B) NODUPREC C) UNIQUE D) NOOVERWRITE Answer: A Explanation: NODUPKEY removes observations that have identical values for all BY variables, keeping only the first occurrence. **Question 10. When using the BY statement in a DATA step, which automatic variables indicate the first and last observation in each BY group? ** A) FIRST. and LAST. B) START. and END. C) FIRST and LAST. D) BEGIN. and FINISH. Answer: A Explanation: SAS creates temporary variables named FIRST.variable and LAST.variable for each BY variable to flag the first and last record in each group. Question 11. Which SAS statement creates a one-to-many merge when the master data set has multiple observations per key? A) MERGE master detail; BY key; B) SET master detail; BY key; C) MERGE master(detail); BY key;
D) PROC SQL; SELECT * FROM master LEFT JOIN detail; Answer: A Explanation: A MERGE with a BY statement performs a one-to-many merge when the “detail” data set contains more than one observation for a given BY value. Question 12. In PROC SQL, which clause is used to limit the rows returned to those that meet a condition after grouping? A) WHERE B) HAVING C) FILTER D) SELECT Answer: B Explanation: HAVING filters groups after the GROUP BY aggregation, whereas WHERE filters rows before grouping. Question 13. Which of the following SAS functions returns the weekday name (e.g., “Monday”) for a SAS date value? A) WEEKDAY(date) B) DAYNAME(date) C) WEEKNAME(date) D) PUT(date, WEEKDATE.); Answer: D Explanation: Using the PUT function with a weekday format (e.g., WEEKDATE.) converts a SAS date to its weekday name. **Question 14. What does the %LET statement do in the SAS Macro Facility? **
Question 17. Which ODS destination creates output in Rich Text Format (RTF) suitable for Microsoft Word? A) ODS HTML; B) ODS PDF; C) ODS RTF; D) ODS LISTING; Answer: C Explanation: ODS RTF routes SAS output to an RTF file, which can be opened and edited in Word. Question 18. Which PROC step would you use to generate a frequency table that also displays cumulative frequencies? A) PROC MEANS; B) PROC FREQ; C) PROC UNIVARIATE; D) PROC TABULATE; Answer: B Explanation: PROC FREQ produces frequency tables and, with the CUM option, can display cumulative frequencies. Question 19. Which SAS function extracts the month component from a SAS date value? A) MONTH(date) B) MDY(date) C) DATEPART(date) D) INTCK('month',0,date) Answer: A
Explanation: The MONTH function returns the month number (1-12) from a SAS date. Question 20. In PROC TRANSPOSE, which statement identifies the variable whose values become column names in the transposed data set? A) VAR B) ID C) BY D) LABEL Answer: B Explanation: The ID statement tells PROC TRANSPOSE to use the values of the specified variable as the names of the new columns. Question 21. Which option on PROC IMPORT automatically determines the appropriate variable type for each column in a CSV file? A) GUESSINGROWS=MAX B) DBMS=CSV; C) GETNAMES=YES; D) MIXED=YES; Answer: A Explanation: GUESSINGROWS specifies how many rows SAS reads to guess variable types; setting it to MAX forces SAS to examine the entire file. Question 22. Which SAS function converts a numeric SAS date to a character string using a user-defined format? A) INPUT(date, myfmt.); B) PUT(date, myfmt.); C) FORMAT(date, myfmt.);
Answer: A Explanation: DISTINCT removes duplicate rows from the SELECT output. Question 26. Which option on PROC MEANS tells SAS to create an output data set containing the computed statistics? A) OUT= B) SAVE= C) DATA= D) RESULT= Answer: A Explanation: The OUT= option creates a SAS data set that stores the statistics calculated by PROC MEANS. Question 27. Which of the following is the correct syntax to define a global macro variable named REGION with the value “East”? A) %GLOBAL REGION; %LET REGION=East; B) %LET GLOBAL REGION=East; C) %DEFINE REGION=East; D) %MACRO REGION=East; Answer: A Explanation: %GLOBAL declares the variable’s scope, and %LET assigns the value. Question 28. Which SAS function returns the position of the first occurrence of a substring within a character string?
Answer: B Explanation: INDEX(string, substring) returns the 1-based position of the first match, or 0 if not found. Question 29. Which option on the SET statement allows you to read a data set without automatically moving the pointer to the next observation? A) POINT= B) OBS= C) FIRSTOBS= D) NOBS= Answer: A Explanation: POINT= specifies an observation number to read; the pointer does not advance automatically, enabling random access. Question 30. Which SAS function can be used to round a numeric value to the nearest multiple of 0.05? A) ROUND(value, .05); B) CEIL(value/.05).05; C) FLOOR(value/.05).05; D) INT(value/.05)*.05; Answer: A Explanation: ROUND(value, .05) rounds the first argument to the nearest multiple of the second argument.
Answer: B Explanation: PROC MEANS (or PROC SUMMARY) provides those descriptive statistics and allows CLASS grouping for multi-level summaries. Question 34. Which SAS function converts a SAS datetime value to a SAS date value, discarding the time component? A) DATEPART() B) DATETIME() C) DAY() D) INTCK('day',0,datetime) Answer: A Explanation: DATEPART extracts the date portion (number of days) from a datetime value. Question 35. In a DATA step, which statement would you use to temporarily rename a variable for the duration of the step without altering the data set’s metadata? A) RENAME var1=varA; B) ATTRIB var1 RENAME=varA; C) LABEL var1='varA'; D) KEEP var1=varA; Answer: A Explanation: The RENAME= data set option (or statement within a SET) can rename variables for the current step only. Question 36. Which PROC SQL clause is used to sort the output rows of a query? A) ORDER BY
Answer: A Explanation: ORDER BY arranges the result set in the specified order. Question 37. Which SAS function returns the number of words in a character string, using the default delimiters? A) COUNTW() B) WORDCOUNT() C) NUMWORDS() D) SCAN() Answer: A Explanation: COUNTW(string) counts the number of words separated by blanks, commas, etc., using default delimiters. Question 38. Which of the following options on PROC PRINT suppresses the printing of observation numbers? A) NOOBS B) NOPRINT C) OBS= D) LABEL Answer: A Explanation: The NOOBS option removes the default observation number column from the printed output. Question 39. In a DATA step, which function would you use to convert the character variable “$12.2” to a numeric value?
Question 42. Which SAS function returns the day of the month (1-31) from a SAS date value? A) DAY() B) DAYOFMONTH() C) MDAY() D) DATEPART() Answer: A Explanation: DAY(date) extracts the day component from a SAS date. Question 43. In PROC SQL, which keyword is used to create an alias for a calculated column? A) AS B) ALIAS C) RENAME D) LABEL Answer: A Explanation: The AS keyword assigns a temporary name to a column expression. Question 44. Which DATA step option tells SAS to read a raw data file that uses a tab character as the delimiter? A) DLM='09'x B) DSD C) DLM=TAB D) DLM=' '; Answer: A
Explanation: DLM='09'x specifies the ASCII tab character (hex 09) as the delimiter. Question 45. Which ODS statement changes the style template to “STATISTICAL”? A) ODS STYLE=STATISTICAL; B) ODS TEMPLATE=STATISTICAL; C) ODS STYLE=STATISTICAL; D) ODS SET STYLE=STATISTICAL; Answer: C Explanation: ODS STYLE=STATISTICAL; selects the STATISTICAL style for subsequent output. Question 46. Which SAS function can be used to remove all blanks from a character string? A) COMPRESS(string) B) TRIM(string) C) STRIP(string) D) DELETE(string) Answer: A Explanation: COMPRESS removes all specified characters; without a second argument it removes blanks. Question 47. What does the %DO %WHILE macro loop do? A) Repeats the enclosed statements a fixed number of times. B) Executes the block while a condition evaluates to true, checking the condition before each iteration. C) Executes the block while a condition evaluates to true, checking the condition after each iteration.
Question 49. Which SAS function converts a character string to all uppercase letters? A) UPCASE() B) UPPER() C) CAPS() D) HIGHCASE() Answer: A Explanation: UPCASE returns the uppercase version of its argument. Question 50. In a DATA step, which statement would you use to keep only variables var1, var2, and var3 in the output data set? A) KEEP var1 var2 var3; B) DROP var1 var2 var3; C) RENAME var1=var2=var3; D) SELECT var1 var2 var3; Answer: A Explanation: The KEEP statement (or KEEP= data set option) specifies variables to retain. Question 51. Which SAS function returns the number of seconds elapsed since midnight for a SAS time value? A) TIMEPART() B) HOUR() C) SECOND() D) INTCK('second','00:00:00't,time) Answer: A
Explanation: TIMEPART extracts the time-of-day portion (seconds since midnight) from a datetime value; for a pure time value, TIMEPART returns the same number of seconds. Question 52. Which PROC step can be used to compute the interquartile range (IQR) of a numeric variable? A) PROC UNIVARIATE B) PROC MEANS C) PROC FREQ D) PROC CORR Answer: A Explanation: PROC UNIVARIATE provides percentiles, including the 25th and 75th, from which the IQR can be derived. Question 53. Which SAS system option controls the maximum number of observations that can be written to the SAS log in a single DATA step? A) OBS= B) LINESIZE= C) MAXOBS= D) MEMSIZE= Answer: C Explanation: MAXOBS limits the number of observations processed; when set, SAS stops after that many observations, which indirectly limits log output. Question 54. In PROC SQL, which clause allows you to combine the results of two SELECT statements while removing duplicate rows? A) UNION ALL B) UNION