SAS Exam II

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

your data does not require any preprocessing if the observations in all of the data sets occur in which of the following patterns?

(1) ascending or descending character order (2) ascending or descending numeric order (3) the data must be grouped in some way

which of the following can determine the length of a new variable?

(1) the length of the variable's first reference in the DATA step (2) the assignment statement (3) the LENGTH statement

How does SAS determine FIRST.variable?

(1) when an observation is the first in a BY group, SAS sets the value of the FIRST.variable to 1. This happens when the value of the variable changed from the previous observation. (2) for all other observations in the BY group, the value of FIRST.variable is 0

Which one of the following is true when SAS encounters a data error in a DATA step? A. A note is written to the SAS log explaining the error, and the DATA step continues to execute. B. The DATA step stops executing at the point of the error, and no SAS data set is created. C. A note appears in the SAS log that the incorrect data record was saved to a separate SAS file for further examination. D. The DATA step stops executing at the point of the error, and the resulting DATA set contains observations up to that point.

A. A note is written to the SAS log explaining the error, and the DATA step continues to execute.

Which statement is true concerning the execution phase of the DATA step? A. Data is processed in the program data vector (PDV). B. An implied OUTPUT occurs at the top of the DATA step. C. An implied REINITIALIZE occurs at the bottom of the DATA step. D. Variables read from the input data are set to missing when SAS returns to the top of the DATA step.

A. Data is processed in the program data vector (PDV).

ONE Id Char1 111 A 158 B 329 C 644 D TWO Id Char2 111 E 538 F 644 G data WORK.BOTH; set ONE TWO; by Id; run; What is the first observation in the SAS data set WORK.BOTH? A. Id Char Char2 ------ ------ ------- 111 A B. Id Char Char2 ------ ------ ------- 111 E C. Id Char Char2 ------ ------ ------- 111 A E D. Id Char Char2 ------ ------ ------- 644 D G

A. Id Char Char2 ------ ------ ------- 111 A

Which statement is false concerning the compilation phase of the DATA step? A. Initial values are assigned to the variables. B. The program data vector (PDV) is created. C. The DATA step is checked for syntax errors. D. The descriptor portion of the data is created.

A. Initial values are assigned to the variables.

What type of output file does this program create? libname mylib xlsx "s:\workshop\output\test.xlsx"; data class_list; set sashelp.class; run; A. SAS data set B. delimited file C. Microsoft Excel XLS file D. Microsoft Excel XLSX file

A. SAS data set

The following SAS program is submitted at the start of a new SAS session: libname sasdata2019 'SAS-data-library'; data sasdata.sales; set sasdata2019.salesdata; profit=expenses-revenues; run; proc print data=sasdata.sales; run; The SAS data set Salesdata has 10 observations. Which one of the following answers explains why a report fails to generate? A. The DATA step fails to execute because of incorrect library reference. B. Library SASDATA2019 is successfully assigned but data step has the syntax error. C. The SAS data set Sales does not exist in the work library. D. The PRINT procedure statement syntax is incorrect

A. The DATA step fails to execute because of incorrect library reference.

If you run this program, which title or titles appear in the final PROC PRINT results? title1 'The First Line'; title2 'The Second Line'; proc print data=sales; run; title2 'The Next Line'; proc print data=sales; run; title 'The Top Line'; proc print data=sales; run; A. The Top Line B. The Top Line The Next Line C. The Top Line The Second Line D. The Top Line The First Line The Next Line

A. The Top Line

The following SAS program is submitted: data work.new; length word $7; amount= 4; if amount = 4 then word = 'FOUR'; else if amount = 7 then word = 'SEVEN'; else word= 'NONE!!!'; amount = 7; run; Which one of the following represents the values of the AMOUNT and WORD variables? A. amount = 7 word = FOUR B. amount = 7 word = SEVEN C. amount = 4 word = FOUR D. amount =4 word = ' ' (missing character value)

A. amount = 7 word = FOUR

In which phase does the DATA step check for syntax errors? A. compilation B. execution

A. compilation

How can you override a permanent format?

Apply a temporary format in the SAS procedure.

Given the SAS data sets ONE and TWO, and the following SAS program on the right is submitted: ONE X1 XY 11 64 12 21 13 98 14 63 TWO X1 PQ 11 78 11 79 22 84 data WORK.NEW; set ONE; set TWO; run; How many observations are in data set WORK.NEW after submitting the program? A. 2 B. 3 C. 7 D. 6

B. 3

The input data set Shipping contains 5 observations and 3 variables (Product, BoxSize, and Rate). How many observations and variables are in the output data set ShipZones given the following information? data ShipZones; set Shipping; Zone=1; output; Zone=2; Rate=(Rate*1.5); run; A. 5 observations and 3 variables B. 5 observations and 4 variables C. 10 observations and 3 variables D. 10 observations and 4 variables

B. 5 observations and 4 variables

You attempt to read a raw data file and you see the following messages displayed in the SAS LOG: NOTE: Invalid data for Salary in line 4 15-23. RULE: ----+----1----+----2----+----3----+----4----+----5-- 4 120104 F 46#30 11MAY1954 33 Employee_Id=120104 employee_gender=F Salary=. birth_date=-2061 _ERROR_=1 _N_=4 NOTE: 20 records were read from the infile 'c:\employees.dat'. The minimum record length was 33. The maximum record length was 33. NOTE: The data set WORK.EMPLOYEES has 20 observations and 4 variables. What does it mean? A. A compiler error, triggered by an invalid character for the variable Salary. B. An execution error, triggered by an invalid character for the variable Salary. C. The first of potentially many errors, this one occurring on the 4th observation. D. An error on the INPUT statement specification for reading the variable Salary.

B. An execution error, triggered by an invalid character for the variable Salary.

The DATA step debugger in SAS Windowing environment can be used with DATA and PROC steps. A. True B. False

B. False

What does this code do? proc import datafile="d:\collect817\bird_count.csv" dbms=csv out=bird817 replace; run; A. It creates a SAS table named Bird817 in the Work library from the CSV file bird_count and replaces Bird817 whenever the CSV file is updated. B. It creates a SAS table named Bird817 in the Work library from the CSV file bird_count. C. It uses the CSV engine to directly read the data file bird_count.csv. D. None of the above

B. It creates a SAS table named Bird817 in the Work library from the CSV file bird_count.

Given the SAS data sets ONE and TWO, and the following SAS program on the right is submitted: ONE X1 XY 11 64 12 21 13 98 TWO X1 PQ 11 78 11 79 22 84 data WORK.NEW; set ONE TWO; by x1; run; After submitting the program, state number of observations in WORK.NEW and the value of X1 for observation 3. A. Obs = 3, X1 = 22 B. Obs = 6, X1 = 11 C. Obs =6, X1 = 13 D. None of the above

B. Obs = 6, X1 = 11

The following program is submitted: proc sort data=SASUSER.PROJECTS out=PSORT; by Code descending Date Cost; run; Which of the following is true concerning the submitted program? A. The descending option applies to the variable Code. B. The variable Code is sorted by ascending order. C. The PSORT data set is stored in the SASUSER library. D. The descending option applies to the Date and Cost variables.

B. The variable Code is sorted by ascending order.

The following SAS program is submitted. data WORK.TEST; set WORK.PILOTS; if Jobcode='Pilot2' then Description='Senior Pilot'; else Description='Unknown'; run; The value for the variable Jobcode is: PILOT2. What is the value of the variable Description? A. PILOT B. Unknown C. Senior Pilot D. ' ' (missing character value)

B. Unknown

The following SAS program is submitted: libname sasdata 'SAS-data-library'; data test; set sasdata.chemists; if jobcode = 'chem3' then description = 'Senior Chemist'; else description = 'Unknown'; run; The value for the variable JOBCODE is: CHEM3 Which one of the following values does the variable DESCRIPTION contain? A. chem3 B. Unknown C. Senior Chemist D. ' ' (missing character value)

B. Unknown

Which statement disassociates the sales libref? libname sales xlsx 'c:\mydata\midyear.xlsx'; A. libname sales end; B. libname sales clear; C. libname sales close; D. libname sales disassociate;

B. libname sales clear;

Which statement creates the macro variable friends and assigns the value Mike? A. %let &friends = Mike; B. %let friends = "Mike"; C. %let friends = Mike; D. %let &friends = "Mike";

C. %let friends = Mike;

The following SAS program is submitted. data ONE TWO SASUSER.TWO MYLIB.NEW; set SASUSER.ONE; run; Assuming that SASUSER.ONE exists, how many temporary and permanent SAS data sets are created? A. 2 temporary and 1 permanent SAS data sets are created B. 3 temporary and 2 permanent SAS data sets are created C. 2 temporary and 2 permanent SAS data sets are created D. there is an error and no new data sets are created

C. 2 temporary and 2 permanent SAS data sets are created

ONE Id Char1 111 A 158 B 329 C 644 D TWO Id Char2 111 E 538 F 644 G data WORK.BOTH; set ONE TWO; by Id; run; How many observations are in the data set WORK.BOTH? A. 3 B. 4 C. 7 D. 6

C. 7

Consider the following data step. data WORK.NEW; set WORK.OLD; retain Count 10; Count+1; run; The variable Count is created using a sum statement. Which statement regarding Count is true? A. It is assigned a value 0 at compile time. B. It is assigned a value 10 when the data step begins execution. C. It is assigned a value 10 at compile time. D. It is assigned a value of missing at compile time.

C. It is assigned a value 10 at compile time.

A SAS PRINT procedure output of the WORK.LEVELS data set is listed below: Work.Levels Obs name level ------------------------- 1 Frank 0 2 Joan 1 3 Jose 2 4 Burt . 5 Kelly 3 6 Juan 0 data work.expertise; set work.levels; if level = . then expertise = 'Unknown'; else if level = 0 then expertise = 'Low'; else if level=1 or 2 then expertise='Medium'; else expertise = 'High'; run; Which of the following values does the variable EXPERTISE contain? A. Low, Medium, and High only B. Low, Medium, High, and Unknown only C. Low, Medium, and Unknown only D. Low, Medium, High, Unknown, and ' ' (missing character value)

C. Low, Medium, and Unknown only

What statement is used to read a SAS data set in a DATA step? A. DATA statement B. WHERE statement C. SET statement D. assignment statement

C. SET statement

What does the following program create? libname sales xlsx 'c:\mydata\midyear.xlsx'; data sales.q1_2018; set sasdata.qtr1_2018; run; data sales.q2_2018; set sasdata.qtr2_2018; run; A. two SAS tables: sales.q1_2018 and sales.q2_2018 B. two Excel workbooks: sales.q1_2018 and sales.q2_2018 C. two worksheets in the Excel workbook: midyear: q1_2018 and q2_2018 D. two worksheets in the Excel workbook: sales: q1_2018 and q2_2018

C. two worksheets in the Excel workbook: midyear: q1_2018 and q2_2018

What is the sequence of statements in terms of compile-time and execution-time statements as they are executed within a data step?

Compile-time statements are processed first and can be processed in any order. Execution-time statements are processed second and run in the order of sequence

Suppose you have submitted a SAS program that contains spelling errors. Which set of steps should you perform, in the order shown, to revise and resubmit the program?

Correct the errors. Clear the SAS log. Resubmit the program. Check the Output window. Check the SAS log.

After a SAS program is submitted, the following is written to the SAS LOG: 105 data WORK.JANUARY; 106 set WORK.ALLYEAR(keep=Product Month Quantity Cost); 107 if Month='JAN' then output WORK.JANUARY; 108 Sales=Cost * Quantity; 109 drop=Month Quantity Cost; ----- 22 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, , <=, <>, =, >, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=. 110 run; What data set option could be attached to WORK.JANUARY to replace the DROP statement that generated the error in the log? A. (drop Month Quantity Cost) B. (drop Month, Quantity, Cost) C. (drop=Month, Quantity, Cost) D. (drop=Month Quantity Cost)

D. (drop=Month Quantity Cost)

ONE Id Char1 111 A 158 B 329 C 644 D TWO Id Char2 111 E 538 F 644 G data WORK.BOTH; set ONE TWO; by Id; run; In how many observations do we have the value of Char2 missing? A. 2 B. 3 C. 0 D. 4

D. 4

Consider the small raw data file and program shown below. What is the value of Count after the fourth record is read? data work.newnums; infile numbers; input Tens 1-2; Count +Tens; run; 1---+----10 10 20 . 40 50 A. Missing B. 0 C. 30 D. 70

D. 70

The SAS data set WORK.ONE contains a numeric variable named Num and a character variable named Char. WORK.ONE Num Char ---- ---- 1 23 3 23 1 77 The following SAS program is submitted. proc print data=WORK.ONE; where Num='1'; run; What is the output? A. Num Char ---- ---- 1 23 B. Num Char ---- ---- 1 23 1 77 C. Num Char ---- ---- 1 23 3 23 1 77 D. No output is generated

D. No output is generated should be Num=1

ONE X1 XY 12 64 11 21 13 98 14 63 TWO X1 PQ 11 78 11 79 22 84 data WORK.ONE; set ONE TWO; by X1; run; How many observations are in data set WORK.ONE after submitting the program? A. 4 B. 3 C. 7 D. None of the previous options

D. None of the previous options

Which DATA step statement indicates to continue processing the last row of a BY group? A. if First.JobTitle; B. where Last.JobTitle=1; C. where First.JobTitle=1; D. None of the previous options

D. None of the previous options

Which statement describes a characteristic of the SAS automatic variable _ERROR_? A. The _ERROR_ variable maintains a count of the number of data errors in a DATA step. B. The _ERROR_ variable is added to the program data vector and becomes part of the data set being created. C. The _ERROR_ variable contains the number of the observation that caused the data error. D. The _ERROR_ variable can be used in expressions in the DATA step.

D. The _ERROR_ variable can be used in expressions in the DATA step.

Which one of the following statements is true regarding the SAS automatic _ERROR_ variable? A. The _ERROR_ variable contains the values 'ON' or 'OFF'. B. The _ERROR_ variable contains the values 'TRUE' or 'FALSE'. C. The _ERROR_ variable is automatically stored in the resulting SAS data set. D. The _ERROR_ variable can be used in expressions or calculations in the DATA step.

D. The _ERROR_ variable can be used in expressions or calculations in the DATA step.

The following SAS program is submitted: data ONE TWO SASUSER.TWO set SASUSER.ONE; run; Assuming SASUSER.ONE exists, how many temporary and permanent SAS data sets are created? A. 2 temporary and 1 permanent SAS data sets are created B. 3 temporary and 2 permanent SAS data sets are created C. 2 temporary and 2 permanent SAS data sets are created D. there is an error and no new data sets are created

D. there is an error and no new data sets are created

In which of the two phases, compilation or execution, are data values written to the output data set?

Execution Phase

which of the following statements is false when you use the BY statement with the SET statement?

FIRST. and LAST. are stored in the data set

which temporary variables are available for DATA step programming during BY-group processing only, but are not added to the data set?

FIRST.variable and LAST.variable

State two methods to control the selection of observations within a data set

IF statement, WHERE statement, Options 'firstobs=' and 'obs='

Give two DATA step statements that are required to read from an external raw data file (e.g. q1.txt).

INFILE and INPUT statements

Is it possible to execute the following code without getting an error? Data test; If sex='Male' then drop age; Run;

No. By default, compile-time statements, such as DROP, cannot be conditionally executed.

During the execution phase in a data step, does input buffer always store the values of the record?

No. If a SAS data set is created from another SAS data set, then SAS by passes the input buffer and directly places the values in the PDV.

Can a where statement be applied to a data step with an input statement?

No. where statements cannot be applied to data steps with an input statement. Where statement requires a set, merge or update statement if specified within a data step.

What happens if you submit the following program? proc sort data=cert.diabetes; run; proc print data=cert.diabetes; var age height weight pulse; where sex='F'; run;

The PROC SORT step generates errors and stops processing, but the PROC PRINT step runs successfully, printing observations in their original (unsorted) order

When using the IF statement to change a variable's value conditionally, does the change take place in the input buffer or the PDV?

The change takes place in the PDV because the input buffer only stores the original data values

If the compilation phase results in an error, is the data set created?

The data set is not created.

What would be the arrangement of variables if the PRINT procedure did not have a VAR statement?

The order of the variables is determined by the physical position of the variables in the data set

In the PRINT procedure, what effect does the BY statement have?

This is to output a separate listing for each BY group.

State one method for applying a subset condition and restricting the number of observations displayed when using the PROC PRINT. For example, how can you list only the male patients within the first 20 records?

WHERE gender='Male'; run;

What is the problem with the following code? Data test; Set abc; If x=1 then q1='Ab'; else if x=2 then q1='Alma'; Run;

Without a LENGTH statement to specify the length of variable q1, the length will be set to 2 since "Ab" is the first data value seen by SAS. This will cause "Al" to be stored for "Alma" when x = 2.

Is it possible to use the RETAIN statement to preserve a character string in a character variable?

Yes

what are the temporary variables that can be helpful when debugging a DATA step?

_N_ and _ERROR_

How can you tell whether you have specified an invalid option in a SAS program?

a SAS log message indicates that an option is not valid or not recognized

What happens if you submit the following program? proc sort data=cert.stress out=maxrates; by maxhr; run; proc print data=maxrates label double noobs; label rechr='Recovery Heart Rate; var resthr maxhr rechr date; where toler='I' and resthr > 90; sum fee; run;

a SAS log message might indicate that a quated string has become too long or that the statement is ambiguous

at the start of DATA step processing, during the compilation phase, variables are created in the program data vector (PDV) and observations are set to which of the following? a. 0 b. missing c. there are no observations

c. there are no observations

which statement correctly describes a BY group?

it includes all observations with the same BY value

What types of errors can the PUTLOG statement help you resolve?

logical errors

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 the following

missing

When new variables are created, how are they added to the existing variables when unsorted?

new variables are added to the end (the right)

unless otherwise directed, how does the DATA step execute?

once for each record in the input file

which program contains an error?

proc print data=stresstest; label totaltime='Total Duration of Test'; drop sumsec; run;

which program creates an output where a character type is sorted in A-Z format?

proc sort data=cert.credit; by type; run;

if you want to sort your data and create a temporary data set named Calc to store the sorted data, which of the following steps should you submit?

proc sort data=finance.dividend out=work.calc; by account; run;

a syntax error occurs during what action?

program statements do not conform to the rules of the SAS language

Consider the IF-Then statement shown below. When the statement is executed, which expression is evaluated first? if finlexam>=95 and (research='A' or (project='A' and present='A')) then Grade='A+';

project='A' and present='A'

Are the DROP and KEEP statements used to control selection of variables or observations within a data set?

selection of variables

what happens when SAS cannot interpret syntax errors?

the DATA step still compiles, but it does not execute

which of the following is not written to the output during the compilation phase?

the first observation

which of the following actions occurs at the beginning of an iterations of the DATA step?

the values of variables created in programming statements are reset to missing in the PDV

if you submit the following program, which variables appear in the new data set? data work.cardiat(drop=age group); set cert.fitness(keep=age weight group); if group=2 and age>40; run;

weight

which statement below selects rows satisfying both conditions? - the amount is less than or equal to $5000 - the account is 101-1092 or the rate equals 0.095

where amount <= 5000 and (account='101-1092' or rate eq 0.095);

which of the following statements selects from a data set only those observations for which the value of the variable Style is RANCH, SPLIT, or TWOSTORY?

where style in ('RANCH', 'SPLIT', 'TWOSTORY');

suppose you run a program that causes three DATA step errors. WHat is the value of the automatic variable _ERROR_ when the observation that contains the third error is processed?

1

What is the maximum length of a variable's label?

256

what is the length of the variable Type as created in the DATA step shown below? data work.newloan; set cert.records; TotLoan+payment; if code='1' then Type='Fixed'; else Type='Variable'; length type $ 10; run;

5

What is the length of the variable Car_Type created in this program? data car_type; set sashelp.cars; if msrp>80000 then car_type="luxury"; else car_type="regular"; length car_type $ 9; run; A. 6 B. 7 C. 8 D. 9

A. 6

ONE Id Char1 111 A 158 B 329 C 644 D TWO Id Char2 111 E 538 F 644 G data WORK.BOTH; set ONE TWO; by Id; run; What are the values of ID and Char2 for observation 6? A. 644, Missing B. 538, F C. 644, G D. 538, Missing

A. 644, Missing

Can a where statement include new variables or temporary variables such as _N_?

No. A where statement cannot include new variables or temporary variables such as _N_. This is because the subset condition is applied before the data goes into the PDV.

When creating data sets, if the OUTPUT statement is not specified, is there an implied OUTPUT statement? If so, where is the implied OUTPUT statement located in the DATA step?

Implied OUTPUT exists as the last DATA step statement.

What does SAS do when it encounters a missing variable in the DATA step?

In a DATA step, SAS creates the variable and sets the value to missing for each observation

What does SAS do when it encounters a missing variable in the PROC step?

In a PROC step, an error is generated "ERROR: Variable vname not found." The PROC will not execute.

When using the RENAME= data set option to change a variable's name in the new data set, is it possible to reference the new variable's name within the same DATA step?

It is not possible to reference the new variable's name within the same DATA step. This is because the new name is only available in the new data set

How do you get the PRINT procedure to use the variable's label in the output?

LABEL or SPLIT=, a PROC PRINT option to use variable labels, can be specified.

What is the difference in applying a LABEL statement in a DATA step as compared to applying it in a PROC step?

LABEL statements in the DATA steps are permanent while the ones in the PROC steps are temporary

Is there a difference between specifying the DROP= data set option before OBS= data set option on the same data set?

No, there is no difference. The order of the data set options is irrelevant.

which procedure produces distinct values of variables and can be used to clean your data?

PROC FREQ

What does PROC PRINT display by default?

PROC PRINT displays all observations and variables in the data set, a column for observation numbers on the far left, and variables in the order in which they occur in the data set.

When the source of the errors in the program is not apparent, which statement or statements can you use to examine errors and print messages to the log?

PUTLOG and PUT statements

Which where condition would be executed if you specified a where data set option along with a where statement in the same data step?

SAS applies where data set option and ignores where statement

When using INPUT statement to create SAS data sets from external files, how does SAS determine the order of the variables created?

SAS creates and saves the variables in the order SAS reads the variable from the INPUT statement if no other compile-time statements are specified before the INPUT statement.

What generally happens when a syntax error is detected

SAS stops processing the step in which the error occurred, and the SAS log displays messages about the error

In general, if a SAS procedure does not have the data set name specified, then what data set is used by the SAS procedure?

SAS uses the most recently created data set.

what program correctly reads the data set Orders and creates the data set FastOrdr?

data cert.fastordr(drop=ordrtime); set cert.orders(keep=product units price ordertime); if ordertime<4; Total=units*price; run;

during the compilation phase, SAS scans each statement in the DATA step, looking for syntax errors. which of the following is not considered a syntax error?

incorrect values and formats


Kaugnay na mga set ng pag-aaral

DCCCD GOVT 2305 Glynn Newman: summer course chapters 1-13

View Set

American Politics: Review Quiz for Exam 2

View Set

Google Analytics Certificate Questions

View Set

21 - PMP I Lesson 11 - Sequence Activities & Estimate Activity Duration/20 - PMP I Lesson 10 - Plan Schedule Management & Define Activities/22 - PMP 1 Lesson 12 - Develop Schedule & Control Schedule/23 - Rita's Chapt 6 (Schedule Mgmt)

View Set