SAS Programming Concepts, Exams of Computer Science

Various sas programming concepts, including the use of proc freq, tables statements, data and proc statements, run statements, and other sas syntax and functionality. It addresses topics such as handling missing data, creating and modifying sas data sets, using proc contents, working with libraries and files, and formatting data. Explanations and examples to help users understand and apply these sas programming techniques effectively.

Typology: Exams

2023/2024

Available from 09/20/2024

ROCKY-B
ROCKY-B 🇰🇪

4.4

(16)

40K documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
SAS 1 EXAM -PRACTICE QUESTIONS AND ANSWERS
A record that is being held by a single trailing at sign (@) is automatically released
when:
A. another INFILE statement is executed
B. another value is read from the observation
C. the input pointer moves past the end of the record
D. the next iteration of the DATA step begins - Answers -D
What is the difference between the following two programs?
data finances;
infile 'account.dat';
input type accountnum;
inputamount;
input date date9.;
run;
and
data finances;
infile 'account.dat';
input type accountnum / amount /
date date9.;
run;
A. The step stops processing with errors in the top program because there are multiple
INPUT statements.
B. The step stops processing with errors in the right program because there are slashes
on the INPUT statement.
C. Both steps stop processing with errors.
D. Both programs run correctly and produce the same output data set - Answers -D
What is the difference between a single trailing @ and a double trailing @@?
A. there is no difference, SAS ignores the duplicate @ symbol.
B. the single trailing @ tells SAS to load the next record, and the double trailing @@
tells SAS to hold the record in the buffer.
C. the single trailing @ tells SAS to hold the record and position in the buffer, and the
double trailing @@ tells SAS to release it.
D. The single trailing @ tells SAS to hold the record and position in the buffer. The
double trailing @@ tells SAS to read the variables on the same record one after the
other, only loading a new one when the end of the record in encountered. - Answers -D
Which of the following is false about BY-group processing?
When you use the BY statement with the SET statement,
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download SAS Programming Concepts and more Exams Computer Science in PDF only on Docsity!

SAS 1 EXAM -PRACTICE QUESTIONS AND ANSWERS

A record that is being held by a single trailing at sign (@) is automatically released when: A. another INFILE statement is executed B. another value is read from the observation C. the input pointer moves past the end of the record D. the next iteration of the DATA step begins - Answers -D What is the difference between the following two programs? data finances; infile 'account.dat'; input type accountnum; inputamount; input date date9.; run; and data finances; infile 'account.dat'; input type accountnum / amount / date date9.; run; A. The step stops processing with errors in the top program because there are multiple INPUT statements. B. The step stops processing with errors in the right program because there are slashes on the INPUT statement. C. Both steps stop processing with errors. D. Both programs run correctly and produce the same output data set - Answers -D What is the difference between a single trailing @ and a double trailing @@? A. there is no difference, SAS ignores the duplicate @ symbol. B. the single trailing @ tells SAS to load the next record, and the double trailing @@ tells SAS to hold the record in the buffer. C. the single trailing @ tells SAS to hold the record and position in the buffer, and the double trailing @@ tells SAS to release it. D. The single trailing @ tells SAS to hold the record and position in the buffer. The double trailing @@ tells SAS to read the variables on the same record one after the other, only loading a new one when the end of the record in encountered. - Answers -D Which of the following is false about BY-group processing? When you use the BY statement with the SET statement,

A. FIRST. and LAST. are stored in the data set. B. FIRST. and LAST. identify the first and last observation in each BY group, in that order. C. the DATA step automatically creates two variables, FIRST. and LAST. for each variable in the BY statement. D. the data sets that are listed in the SET statement must be indexed or sorted by the values of the BY variable(s). - Answers -A What is the value of first. variable for the first observation in a BY group? a. 0 b. 1 c. missing d. the first value of the variable - Answers -B In a data set with 100 observations, given the following statement, how many observations will be read? set orion.tests (firstobs = 20 obs = 50); a. 20 observations b. 30 observations c. 31 observations d. 50 observations - Answers -C In a data set with 100 observations, given the following statement, how many observations will be read? set orion.tests (firstobs = 20 obs = 10); a. 10 observations b. 30 observations c. 20 observations d. 0 observations, the obs= value cannot be less that the firstobs= value. - Answers -D By default, PROC FREQ creates a table of frequencies and percentages for which data set variables? a. numeric variables b. character variables c. both character and numeric variables d. none: variables must always be specified - Answers -C What does the TABLES statement do in the PROC FREQ step? a. it tells SAS which table to analyze b. it tells SAS which variables to analyze c. you do not use a TABLES statement in the PROC FREQ step. d. it tells SAS what your table should look like. - Answers -B

I. Windows II. Unix III. Mainframe a. I only b. II only c. I and III only d. I, II, and III - Answers -D What contains information about the processing of the SAS program, including any notes, warnings, and error messages? a. SAS output b. SAS Editor c. SAS Log d. None - Answers -C ________ contains reports generated by most SAS procedures. a. SAS Program Editor Window b. SAS Output Window c. SAS Log Window d. SAS Editor window - Answers -B Where can you type the INCLUDE command to open a SAS program? a. Editor Window b. Enhanced Editor Window c. Command Box d. Run Window - Answers -C Within the Editor, the syntax in your program is ________ to show step boundaries, keywords, variable, and data set names. a. underlined b. in bold c. in bold and underlined d. color-coded - Answers -D Which statement would output only the last observation of each BY group? a. if first.group = 0; b. if last.group = 0; c. if first.group = 1; d. if last.group = 1; - Answers -D When you use more than one variable in the BY statement, a change in the primary variable forces the Last.BY-variable for the secondary variable to equal what? a. the same value as the first variable. b. missing

c. 1 d. 0 - Answers -C Which statement is false regarding the sum statement? a. the sum statement ignores missing values. b. the sum statement requires a retain statement. c. the sum statement initializes the variable to zero before the first iteration of the DATA step. d. the sum statement creates the variable on the left side of the plus sign if it does not already exist. - Answers -B What is the result of putting an output statement without a data set name? a. SAS will ignore the current observation b. SAS will output to every data set on the DATA statement c. SAS will stop processing due to a syntax error d. SAS will not output observations to the data sets on the DATA statement - Answers - B The ________ data set option excludes variables from processing or from output SAS data sets by listing the variables you want in the DATA set. a. DROP b. KEEP c. KEEP = d. DROP = - Answers -C DROP = and KEEP = options apply to what data sets? a. output data sets only b. input data sets only c. both input and output data sets d. neither the input nor the output data sets - Answers –C After submitting a program, what should you always do first? a. check your program output b. check your log c. check your code d. check your editor window - Answers -B What terms does SAS use in the log to refer to table, column, and row? a. table, column, and row b. data, var, obs c. SAS does not use terminology in the log d. Data Set, Variable, Observation - Answers -D As you continue to submit your programs, SAS will write to a/the ______________ of the log. a. top

c. PROC CONTENTS d. PROC DESC - Answers -C Missing numeric variables are identified by a. a blank b. a period (.) c. a pound sign (#) d. a null value - Answers -B Numeric characters are stored in how many bits/bytes of storage by default? a. 8 bits b. 8 bytes c. 1 bit d. 1 byte - Answers -B Which of the following SAS names is valid? a. 2006PromCosts b. yr 2006 PromCOsts c. $2006Prom_Costs d. _2006Prom_Costs - Answers -D You have a SAS date value of 0. What date does this represent? a. January 1, 1970 b. January 1, 1960 c. January 1, 1900 d. January 1, 2000 - Answers -B By default, PROC PRINT displays a. all observations and variables b. all observations, variables, and an obs column c. all observations, variables, and an id column d. all observations, variables with descriptor information - Answers -B What command can you use to retrieve previously submitted code? a. SUBMIT b. RETRIEVE c. RECALL d. LAST - Answers -C What are options? a. They tell SAS you want that procedure to be processed differently than its default behavior. b. they tell SAS you want to add additional features to that procedure. c. they tell SAS you don't want that procedure to include those items d. they do not make any changes to the procedure - Answers -A

What line of code do we use to best fix the problem of unbalanced quotes, regardless of the type of quote missing? a. * ' ; run; b. * ' ; * " ; c. * ' ; * " ; run; d. * ' " ; run; - Answers -C How does SAS accumulate your programs in the buffer? a. the last thing that is added to the buffer is the first thing that is available to remove. b. the first thing that is added to the buffer is the first thing that is available to remove. c. SAS does not accumulate your programs in a buffer. d. the last thing that is added to the buffer is the last thing that is available to remove. - Answers -A Differentiate between a data step and a proc step. a. DATA steps are typically used to process SAS data sets and PROC steps are typically used to process SAS data sets. b. DATA steps are typically used to create SAS data sets and PROC steps are typically used to process SAS data sets. c. DATA steps are typically used to process SAS data sets and PROC steps are typically used to process SAS data sets. d. DATA steps are typically used to modify SAS data sets and PROC steps are typically used to modify SAS data sets. - Answers -B When you execute a SAS program, the output generated by SAS is divided into what two major parts? a. SAS log and SAS output b. SAS log and SAS editor c. SAS output and SAS code d. SAS log and SAS descriptor portion - Answers -A What are all of the ways to open a SAS program? a. INCLUDE in the command box, file -> open, and open toolbar shortcut b. file -> open, and open toolbar shortcut c. INCLUDE in the command box, and file -> open d. INCLUDE in the command box, and open toolbar shortcut - Answers -A You need to view your log. What are the ways you can bring the log forward? a. LOG command in the command box, and click on the Log Tab b. view menu -> Log and click on the Log Tab c. view menu -> Log and LOG command in command box d. view menu -> Log, LOG command in command box, and click on the Log tab. - Answers -D What can you do if you lose your previously submitted code? a. recall menu -> last submit

c. LIBNAME d. ALL - Answers -D You will needs to submit a libname statement for every different ___________. a. SAS data set b. folder c. data file d. .sas file - Answers -B Which statement prints only a list of all the files stored in the library named colleges? a. proc contents data=colleges_all_.nods; b. proc contents data=colleges_all_nods; c. proc contents data=colleges.all_noobs; d. proc contents data=colleges.all nods; - Answers -D Which of the following statements will list all the SAS files in the library named scholarships and the descriptor potion of every data set in that library? a. proc contents data=scholarships.all nods; b. proc contents data=scholarships.all; c. proc contents data=scholarships_all; d. proc contents data=scholarshipsall_.; - Answers -B What does it mean that the libname statement is global? a. it applies only to the procedure that follows the libname statement. b. it requires a run statement. c. it remains in effect until the SAS session is closed or you submit another libname statement for the same libref. d. it will remain in effect until SAS in uninstalled. - Answers -C Which libref name below follows the rules for naming conventions? a. top_universities b. 5topuniv c. top$univ d._topuniv - Answers -D Which of the following statements regarding libraries is false? A. each time you start a session, you do not need to assign a libref to each permanent SAS data library that contains files that you want to access in that session. B. when the session is ended or you delete a libref, SAS no longer has access to the files in the library; however, contents of the library still exist on your operating system. C. you can use the LIBNAME statement to reference not only SAS files but also files that were created with other software products, such as database management systems. D. you can store the LIBNAME statement with any SAS program so that the SAS data library is assigned each time the program is submitted. - Answers -A

The CONTENTS procedure creates SAS output that provides the following except: a. the contents of the library b. the descriptor portion of the individual data set. c. the data portion of the individual data set. d. variable names - Answers -C Which function correctly calculates the average of the variables Var1, Var2, Var3, and Var4? a. mean(of var1-var4) b. mean(of var1, var4) c. mean(var1-var4) d. mean(var1, var4) - Answers -A Within the data set Hrd.Temp, PayRate is a character variable and Hours is a numeric variable. What happens when the following program is run? data work.temp; set hrd.temp; Salary = payrate*hours; run; a. SAS converts the values of Hours to character values. A message is written to the log. b. SAS coverts the values of Hours to character values. No message is written to the log. c. SAS converts the values of PayRate to numeric values. No message is written to the log. d. SAS converts the values of PayRate to numeric values. A message is written to the log. - Answers -D A typical value for the character variable Target is 123, 456. Which statement correctly converts the values of Target to numeric values when creating the variable TargetNo? a. TargetNo = input(target, comma6.); b. TargetNo = input(target, comma7.); c. TargetNo = put(target, comma6.); d. TargetNo = put(target, comma7.); - Answers -B A typical value for the numeric variable SiteNum is 12.3. Which statement correctly converts the values of SiteNum to character values when creating the variable Location? a. location = dept || '/' || put(sitenum, 4.); b. location = dept || '/' || put(sitenum, 3.); c. location = dept || '/' || input(sitenum, 4.); d. location = dept || '/' || input(sitenum, 3.); - Answers -A Which MDY function creates the date value for January 3, 1995?

b. A comma, the INPUT statement c. A space, the INFILE statement d. A comma, the INPUT statement - Answers -C How is the variable Amount labeled and formatted in the PROC PRINT output? data credit; infile 'creddata.dat'; input @1 Account $5. @7 Name $19. @27 Type $1. @29 Transact $7. @37 Amount 14.; label amount='Amount of Loan'; format amount dollar12.2; run; proc print data=credit label; label amount='Total Amount Loaned'; format amount comma10.; run; a. No label for Amount, COMMA10. format b. label is Amount of Loan, format is DOLLAR12. c. label is Total Amount Loaned, format COMMA10. d. The PROC PRINT step does not execute because two labels and two formats are assigned to the same variable. - Answers -C Which SAS statement should be used to correctly specify the raw data file house.dat below, if you wanted to use the DSD option? 1 2 3 1---+----0---+----0---+----0- 2STORY 1810 4 SHEPPARD AVENUE CONDO 1200 2 RAND STREET RANCH 1550 3 MARKET STREET a. infile 'house.dat' dsd; b. infile 'house.dat' dlm=' '; c. input Type $ Footage Bedrooms Location $ dsd; d. infile 'house.dat' dsd dlm=' '; - Answers -D Which option lets you treat consecutive delimiters as a missing value? a. DLM= b. PAD c. MISSOVER d. DSD - Answers -D What does the note LOST CARD mean when you see it in the SAS log? a. SAS lost the pointer in the raw data file and the data set is now corrupted. b. A record from the raw data file was not written to the SAS data set.

c. The pointer in the input buffer has been dropped. d. This is not a valid note for the SAS log. - Answers -B What does the MISSOVER option tell SAS? a. To treat consecutive delimiters as a missing value. b. To load the next record if a value is not found at the end of a record. c. To not load the next record if a value is not found at the end of a record. d. To assign missing values to numeric variables above a certain value. - Answers -C How can you store formats and labels permanently with a SAS data set? a. This is not possible. b. You supply them in a PROC step. c. You supply them in a DATA step. d. You must supply them in both the DATA and PROC steps. - Answers -C Which of the following is not true about setting a variable's length? a. It can be set by the LENGTH statement only. b. A variable's length is set to 8 bytes by default with delimited input. c. The length can be set using an informat on the INPUT statement. d. A numeric variable is set to a length of 8 bytes by default, regardless of style of input.

  • Answers -A At the beginning of the execution phase, the value of N is 1, the value of ERROR is 0, and the values of the remaining variables are set to a. 0 b. 1 c. Missing d. Undefined - Answers -C Which of the following actions occurs at the end of the DATA step at compile time? a. The values of variables created in programming statements are re-set to missing in the program data vector. b. The automatic variables N and ERROR are incremented by one. c. The descriptor portion of the data set is written. d. The DATA step stops execution. - Answers -C Which statement correctly re-defines the values of the variable Allowance as 100 percent higher than its current value? a. allowance=200; b. allowance=allowance1.00; c. allowance = allowance2; d. allowance=allowance+(allowance2.00); - Answers -C Which statement correctly creates a SAS data set using a SAS data set as input? a. set vacation.beach;

if code = '1' then Type='Fixed'; else Type='Variable'; length type $ 10; run; a. It depends upon the first value of Type b. 5 c. 8 d. 10 - Answers -B Which set of statements is the most efficient equivalent to the code shown below? if code='1' then Type='Fixed'; if code='2' then Type='Variable'; if code ^= '1' and code^='2' then Type='Unknown'; a. if code='1' then Type='Fixed'; else if code='2' then Type='Variable'; else Type='Unknown'; b. if code='1' then Type='Fixed'; if code='2' then Type='Variable'; else Type='Unknown'; c. If code='1' then Type='Fixed'; else code='2' then Type='Variable'; else Type='Unknown'; d. if code='1' then Type='Fixed'; then code='2' then Type='Variable'; else Type='Unknown'; - Answers -A Which of the following PROC PRINT steps correctly creates and uses labels? a. proc print data=univ.public label; label acc='ACC Universities'; run; b. proc print data=univ.public; label ACC='ACC Universities'; run; c. proc print data univ.public label noobs; run; d. proc print univ.public label; run; - Answers -A The default title is a. The SAS System b. SAS Programming c. SAS v. d. The SAS System v.9 - Answers -A

A title or footnote statement cancels all titles or footnotes with ____________ numbers. a. lower b. the same c. no d. higher - Answers -D Which is the correct SAS statement to turn off the date in your output window? a. options dateoff; b. options nodate; c. proc print data=test.example nodate; d. proc print data=test.example dateoff; - Answers -B Which is the correct SAS statement to suppress the date, set the page number to 1, the page size to 66, and the line size to 100? a. options nodate number pageno=1 ls=100 ps=66; b. options nodate number pageno=1 ps=100 ls=66; c. options nodate number=1 ls=100 ps=66; d. options nodate number pageno=1 ls=100 ps=66; - Answers -A Which of the following statements about formatting values is true? a. the format statement and the format procedure are both used to create new formats. b. the format statement creates new formats and the format procedure applies the formats to values. c. the format statement applies formats to values and the format procedure is used to create new formats. d. the format statement is used in the format procedure to name the new format. - Answers -C Which of the following statements would apply the DOLLARw.d format to the value Tuition if you want to show the dollar sign, a comma, and no decimal places. (The largest value is 15000). a. format tuition dollar5.0; b. format tuition dollar5; c. format tuition dollar8; d. format tuition dollar8.; - Answers -D Which of the following SAS statements correctly sets the display width to 10 for the character variable LastName? a. format lastname $10.; b. format lastname 10.; c. format lastname $10; d. format lastname w10.; - Answers -A Which output is correct if the variable was formatted using the comma7.2 format and the value is 1428.21? a. 1,

Ranges in the VALUE statement can specify all of the following except: a. a single value, such as 24 or 'S' b. a range of character values, such as 'A'- 'M' c. a range of numeric value, such as 0- d. a list of numeric and character values separated by commas, such as 90, 'B', 180, 'D', 270 - Answers -D Which keyword can be used to label missing values as well as any values that are not specified in a range? a. MISS b. MISSING c. OTHER d. LOW - Answers -C The format $JOBFMT was created in a FORMAT procedure. Which FORMAT statement will apply it to the variable JobTitle in the program output? a. format jobtitle $jobfmt; b. format jobtitle $jobfmt.; c. format jobtitle = $jobfmt; d. format jobtitle = '$jobfmt'; - Answers -B What is the purpose of the INFILE statement? a. the INFILE statement is to tell SAS that you are reading from a raw data file, and which file to read from. b. the INFILE statement names the SAS variables c. the INFILE statement creates a spot in memory for each variable d. the INFILE statement tells SAS to load the record into the input buffer - Answers -A All of the following are created at compile time, except a. the input buffer b. the program data vector c. the descriptor portion d. the data portion - Answers -D What is the product of each of the phases of the DATA step? a. the compilation phase creates the data portion and the execution phase creates the descriptor portion b. the compilation phase creates the descriptor portion and the execution phase creates the data portion. c. the compilation phase and the execution phase create the data portion. d. the compilation phase and the execution phase create the descriptor portion. - Answers -B What is the purpose of the INPUT statement? a. the INPUT statement creates a spot in memory for each variable

b. the INPUT statement tells SAS to create the input buffer c. the INPUT statement starts a DATA step and names the SAS data set being created d. the INPUT statement tells SAS you are reading from a raw data file and where to find that file - Answers -A In the statement INPUT input-specifications;, what is the purpose of input- specifications? I. names the SAS variables II. identifies the variables as character or numeric III. specifies the locations of the fields in the raw data a. I & II b. I & III c. I, II, & III d. II & III - Answers -C What is meant by 'automatic output'? a. the pointer in the raw data file moves down to the next line in the raw data file. b. in the Data Step, when SAS encounters a RUN statement, SAS will output what is in the PDV to the data set. c. character variables are initialized to a blank, and numeric variables are initialized to a period in the PDV. d. when at the RUN statement, SAS will return to the next record in the data file. - Answers -B Which is not an advantage of formatted input? a. it can be used to read character variables that contain embedded blanks b. you do not need to know where variables begin and end c. fields do not have to be separated by blanks or other delimiters d. only nonstandard data values can be read - Answers -B Which is an example of standard numeric data? a. -34. b. $24,234. c. 1, d. 50% - Answers -A The COMMAw.d informat can be used to read which of the following values? I. 12, II. $177. III 18% a. I only b. I & II