You are on page 1of 31

Sample SAS certification Questions

(Questions asked in Base SAS certification exam)


Values and names may be different: 1.) Which ODS command closes the HTML file?? Answer: ODS HTML CLOSE; 2.) Which is the correct statement: a.) ODS HTML FILE = file; b.) ODS FILE HTML = file c.) ODS FILE = file d.) ODS HTML = file Answer: a 3.) data temp; set lib1.x lib2.y; length jobcode $12.; run; What would be the length of Jobcode in temp? a.) b.) c.) d.) Answer: c 4.) PROC SORT data = lib.temp out = temp2; By subjid; Run; In which library temp2 is made? a.) b.) c.) d.) WORK SASUSER LIB SYNTAX ERROR 5 8 12 Syntax Error

Answer: a 5.) options obs = 500; Data TEMP; Set test(firstobs = 75); Run; What will be the number of observations in temp dataset? a.) 424 b.) 425 c.) 500 d.) 75 e.) 426 Answer : e

6.)

PROC SORT data = temp; BY Descending JOBCODE SALARY; RUN; Temp DATASET

JOBCODE X1 X2 X2 A1 A2 A2 What will be the output?? Answer:

SALARY 100 100 200 100 200 200

AGE 20 10 20 10 10 40

Temp DATASET JOBCODE X2 X2 X1 A2 A2 A1 SALARY 100 200 100 200 200 100 AGE 10 20 20 10 40 10

7.) PROC SORT DATA = TEMP; By Jobcode DESCENDING Salary; RUN; What will be the first observation? (Apply this on dataset created in last question) Answer:

Temp DATASET JOBCODE A1 A2 A2 X1 X2 X2 8.) DATA TEMP; MERGE X1 X2; BY ID; RUN; SALARY 100 200 200 100 200 100 AGE 10 10 40 20 20 10

How many observations and variables will be there in temp dataset? X1 DATASET ID 1 2 NAME ANKUR VIJAY X2 DATASET ID 1 1 2 2 CLASS A B B A

Answer: 3 variables and 4 observations 9.) DATA TEMP; MISSING CODE RUN; What is the correct missing code? a.) Merge Test1 /*Test1 contains JOBCODE */ Test2(rename = (Jcode = JOBCODE)); b.) Merge Test1 /*Test1 contains JOBCODE */ Test2(rename = (JOBCODE = JCODE)); c.) Merge Test1 (rename = (Jcode = JOBCODE)) /*Test1 contains JOBCODE */ Test2; d.) Merge Test1 /*Test1 contains JOBCODE */ Test2(rename Jcode = JOBCODE)); Answer: a 10.) data temp; test = X; select(test); when(Y) Name = Ank; when(X) Name = Ankur; when(Z) Name = ; end; run; What is the output? a.) Ankur b.) Ank c.) Missing (character missing value) d.) Ankur Answer: Good Question. I would suggest you to try this question on your system. The answer is b. Its because during compilation time the length of variable Name is set as 3 (see the first case Y) and hence even if the case X is satisfied the output will still be Ank. 11.) data _null_; put ankur; run; Where will the ouput(ankur) be written? a.) In Last file opened

b.) In dataset _null_ c.) Syntax error d.) Log Answer: d 12.) What is true about _ERROR_ variable? a.) Can be used in assignments/calculation in datastep. b.) This variable appears in output dataset c.) Will have values YES or NO d.) Will have values TRUE or FALSE Answer: a 13.) What is true about array variables? a.) They are temporary variables created in datastep. b.) They are output in dataset. c.) Can contain numeric and character values at same time. d.) Cannot be used in assignment statement. Answer: b 14.) What is the system option to print TIME in OUTPUT window? a.) DATETIME b.) TIME c.) DATE d.) SECOND Answer: c 15.) PROC Report question on difference between display and across. 16.) PROC Report question on difference between group and order. 17.) DATA TEMP; X= 13MAR2000d; RUN; What is stored in x? a.) 13MAR2000 b.) Corresponds to days from 01 Jan 1960: 14682 c.) 13/03/2000 d.) Corresponds to days from 01 Jan 1960: 135680 Answer: b (the choices mentioned in b and c points both were there. Hence I had to calculate the number of days from 01 Jan 1960. Although a rough idea will do. There was a digit difference between 2 options) 18.) 1----5----10--(data in file asa) 03132000 data temp; infile asa; input date : MMDDYY10.; run; What will be stored in date? a.) 01022000 b.) 02FEB2000 c.) 14682(number of days from 1st jan 1960)

d.) 02 January Answer: c (Note: the date is stored in dataset as SAS date) 19.) data test; n=1; do while(n lt 6); n+1; end; run; What will be the value of n at the end of datastep? a.) 7 b.) 5 c.) 6 d.) 8 Answer: c (Good Question again. This question will tell you that before marking any choice think twice. Actually it comes out of do while loop when n is 6 and will not execute the statement n+1;) 20.) GOOD QUESTION Proc Format; Value ag 1-50 = less 51-100 = greater; Run; Data test; X = 50.5; Format x ag.; Run; What will be the output of dataset test? a.) less b.) greater c.) great d.) 50.5 e.) systax error Answer: d ( I would suggest please try it on your PC and check for different values. Whenever SAS does not find a mapping for some value in the format it print the value as it is.) 21.) data test; dat = 13MAR2000d; format dat WEEKDATE.; run; What will be the value of dat in output dataset? a.) 13MAR2000 b.) Monday, March 13, 2000 c.) Mon, March 13, 2000 d.)14682 (nmber of days from 1st jan 1960) Answer: b 22.) data temp; set x; run; missing code data test;

set y; run; What will be the missing code to reset the page number ? a.) OPTIONS PAGENO = 1; b.) OPTIONS RESET PAGENO = 1; c.) OPTIONS RESET PAGENUMBER = 1; d.) OPTIONS PAGENUMBER = 1; Answer: a 23.) DATA TEMP; Infile filename; Input ID $5 @; If ID = RAMES then input Y $6 Z $10 @; else ID = VIJAY then input R $2 @; Input age 5.; RUN; How many lines are read from input file during one execution of dataset? a.) 2 b.) 1 c.) 3 d.) 4 Answer: b (note only one execution not complete dataset) 24.) How to write comma separated file? a.) FILE filename dsd = ,; b.) FILE filename dlm = dsd = ,; c.) FILE filename dlm = ,; d.) FILE filename csv = ,; Answer: c 25.) 1----5----10----15----(file abc) RAM,,20 RAJU,SHARMA,24 DATA temp; Infile abc dsd; Input FNAME $ LNAME $ AGE; RUN; What will be the value of LNAME for 1st observation? a.) , b.) blank character value c.) SHARMA d.) syntax error Answer: b 26.) data temp; set test1(in = a) /* 2 observations*/ test2(in=b); /* 5 observations*/ if a and b;

run; How many observations will be there in temp dataset? a.) 2 b.) 5 c.) 7 d.) 0 Answer: 0 (Good question, repeated many times. Note a and b). 27.) data temp; set test; /* 100 observations 20 for each ID*/ by ID; if first,ID then name = RAJU; else if ID = RAM then name = RAMU; if last.ID; run; How many observations will be present in temp dataset? a.) 5 b.) 20 c.) 100 d.) 0 Answer: a 28.) Question on PROC PRINT with BY statement; 29.) libname temp abc.sds.as; data temp.X1. set sasuser.X2; run; Which is the correct statement?? a.) In datastep input is read from temporary location and output is written to temporary location. b.) In datastep input is read from permanent location and output is written to temporary location. c.) In datastep input is read from temporary location and output is written to permanent location. d.) In datastep input is read from permanent location and output is written to permanent location. Answer: d 30.) What is the output of DATE9. format? a.)11/31/2000 b.) 31/11/2000 c.) 31NOV2000 e.) 01NOVEMBER2000 Answer: c 31.) Why PROC FSLIST is used? a.) to write to an external file b.) to read from an external file c.) to sort by date d.) not a valid statement

Answer: b 32.) 1----5----10----15----20 (filename = abc) ankur 22 data temp; infile file; input name $1-10 age 15-16; /*missing code*/ run; What is the missing code to write ankur,22 to variable LA; a.) LA = TRIM(name)||,||put(Age,2.); b.) LA = name||,||put(Age,2.); c.) LA = name|| ,||TRIM(put(Age,2.)); e.) LA = put(name)||,||put(Age,3.); Answer: a 33.) data temp; merge test1(keep = ID) test2(keep = ID NAME CLASS AGE); by ID; keep = ID NAME; run; Variables in output dataset? A.) B.) C.) D.) Answer: b ID NAME NAME ID ID NAME CLASS AGE Syntax error

34.) data a; do X=1 to 3 ; input ID NAME $ AGE; end; datalines; 01 vivek 22 02 vital 25 03 rajes 20 ; What will be the number of observations and variables in output dataset?? a.) 3 and 3 b.) 1 and 3 c.) 1 and 4 d.) 3 and 1 Answer: c 35) What informat should be used to read the date variable in the flat file having the values like 02NOV2003? a)DATE9. b)MMDDYY8.

c)MMDDYY10. d) none Answer: a 36) Flat file structure is as below 1----5----10 $1,120 The following code is submitted. data temp; infile file specification; input salary 5; run; What would be the value of SALARY in the dataset TEMP? a)$1,120 b) 2 c). (period) d) Blank value Ans: b Tip: Here the SAS goes to the 5th column and read the value. But if we specify the informat like SALARY 5. then there will be . In the SALARY variable. Please keep in mind that if there is any data error, SAS produces blank values to those variables(i.e . For numeric variables and blank for the character variables). SAS never stops execution when data error occurs. 37) Flat file structure is as below 1----5----10 02032000 The following code is submitted. data temp; infile file specification; input date mmddyy10.; run; what is the value of date in the dataset TEMP? a)02032000 b) 14643, the number of days from jan 1st , 1960 c) 1460000, the number of days from jan 1st , 1960 d) 02/03/2000

Ans: b
38) The following code is submitted data temp; x=14643; y=put(x,mmddyy10.); run; What would be the attributes of variable Y in the dataset TEMP? a) Length of Y is $10. b)Length of Y is 10

c) Length of Y is 8 d)None

Ans: a
39) The following code is submitted data temp; length y $5; x=4; if x=4 then y='four'; else if x=7 then y='seven'; x=7; run; What would be the value of X and Y in the dataset temp? a) b) c) d) X=4 and Y= seven X=7 and Y=seven X=7 and Y=four X=4 and Y=four

Ans: c
40) Flat file structure is as below 1----5----10 dan 23 45 bob 44 50 sue 30 80 mam 40 50 The following code is submitted. data temp; infile file specification; input x $ 1-3; if x='sue' then input age 5-6; else input height 8-9; run; what would be the value of variable AGE in the dataset TEMP when variable X has the value Sue? a) 30 b) 44 c) 40 d) 55

Ans: c
41) Flat file structure is as below (Very good question) 1----5----10 vital reddy 45 vijay 30 sarma 40 The following code is submitted.

10

data temp; infile file specification; input x $ age; if age<=40; run; How many observations will be there in the TEMP dataset? a)3 b)2 c)zero observations d)syntax error

Ans: a
42) The following code is submitted. data temp; salary='20000'; bonus=0.1*salary; run; What would be the value of BONUS variable in the dataset TEMP? a)2000 b)2000 c).(period) d)blank

Ans: b
43) The following code is submitted. data temp; salary=.; if salary=. then salary=100; bonus=10; salary=.; total=sum(salary,bonus); run; What would be the value of TOTAL variable in the dataset TEMP? a)100 b)110 c)10 d).(period)

Ans: c
44) The descriptor portion of the dataset TEMP has the label of variable SALARY as Actual salary. which of the below code changes the label of the variable SALARY to given? a) proc print data=temp label; label salary='given'; run;

11

b) proc print data=temp label; label salary 'given'; run; c) proc print data=temp; label salary 'given'; run; d) proc print data=temp; label salary='given'; run;

Ans: a
45) the dataset XYZ is as below JOBCODE Chem3 data xyz; set temp; if jobcode='CHEM3' then description='senior chemist'; else description='unknown'; run; What is the value of DESCRIPTION variable in the TEMP dataset? a) senior chemist b) unknown c) senior d) blank characters

Ans: b Tip: here we need to use UPCASE (jobcode) in if statement as the character comparison is case sensitive.
46) The TEMP dataset has the values of variables as below X Y Z 150 less than 200 and gt 100 300 which of the below code creates the dataset TEMP with above values in the variables X, Y, and Z. a) data temp; x=150; if 100 le x le 200 then do; y='less than 200 and gt 100'; z=300; end; else do;

12

y='other values'; z=400; end; run; b) data temp; x=150; if 100 le x le 200 then do; y='less than 200 and gt 100'; z=300; else do; y='other values'; z=400; end; run; c) data temp; x=150; if 100 le x le 200 then y='less than 200 and gt 100'; z=300; else do; y='other values'; z=400; end; run; d) None

Ans: a
47) Flat file structure is as below 1----5----10 23 44 The following code is submitted. data temp; infile file specification; input @1 weight 2. @4 height 2.; run; What is the value of HEIGHT variable in the TEMP dataset? a) . (period) b) Blank c) 44 d) 23 48) Following code is submitted. data temp: do i=1 to 3; do j=1 to 4; salary=salary+300; end;

13

end; run; how many observations will present in the dataset TEMP? a)1 b)3 c)2 d)0

Ans: a
49) The dataset XYZ has 5000 observations. options obs=500; proc print data=xyz(firstobs=100 ) run; options obs=max; proc means data=xyz(firstobs=500) run; How many observations processed in each procedure? a) 401 in the proc print and 4501 in the proc means b) 5000 in the proc print and 500 in the proc means c) 500 in the proc print and 5000 in the proc means d) 4501 in the proc print and 401 in the proc means

Ans: a
50) Which of the following code calculates the mean of variables var1, var2, var3, and var4. a) MEAN(var1-var4) b) MEAN(of var1-var4) c) MEAN(var1 var2 var3 var4) d) MEAN(var1)

Ans: b
51) Which of the following code creates the permanent dataset MYDATA from temporary dataset MYDATA? Libname out sas-library; a) data MYDATA; set MYDATA; run; b) data MYDATA; set out.MYDATA; run; c) data out.MYDATA; set MYDATA; run; d) none

14

Ans: c
52) See the code below filename rawdata1 u3x2888.reddy.lib(reddy); libname rawdata2 u3x2888.reddy.saslib data temp; infile missing code; input x y; run; what should be inserted in place of missing code? a)rawdata2 b)rawdata1 c)file d)none

Ans: b
53) what is the procedure to print the data portion of the dataset? a)PROC MEANS b)PROC SQL c)PROC PRINT d)PROC CONTENTS

Ans: c
54) what is the procedure to see the descriptor portion of the dataset? a)PROC MEANS b)PROC SQL c)PROC PRINT d)PROC CONTENTS

Ans: d
55) The variable JOBCODE has length $5 in the dataset TEMP. The same variable present in the dataset TEMP1 and has length $7. data temp2; set temp temp1; run; what would be the length of the variable JOBCODE in the dataset TEMP2? a) b) c) d) 5 7 we cant see the length as data set wont be created due to errors. None

Ans: a Tip: whenever we are concatenating the datasets which are having the same variable names but having the difference in the attributes like Label, length etc.. will be taken from the first dataset that has occurred in the SET statement. Here it is TEMP dataset. 15

56) one question on using same variable in the ID and BY statement of PROC PRINT. 57) What will be the value of variable b in the log when following datastep is submitted? Todays date is 31DEC2004; Data _NULL_; a=month(today()); b=put(a,date9.); put b; run; a) b) c) d) 13JAN1960; syntax error 31DEC2004 12

Ans:a
58) Data a has 12 observations and one variable Date as following. Date_________________________________________________ 01/01/2004 02/01/2004 03/02/2004 04/01/2004 05/01/2004 06/01/2004 07/01/2004 08/01/2004 09/01/2004 10/01/2004 11/01/2004 12/01/2004 How many observations will be there dataset b if the following datastep is submitted? Data b; Set a; Temp = qtr(input(Date,mmddyy10.)); If Temp LE 3; RUN; A) B) C) D) 3 5 9 6

Ans: D
59) What will be the length of variable LEN when the following code is submitted? Data temp; A = I am Bond, James Bond; LEN=SCAN(A,3); Run;

16

a) b) c) d)

4 20 8 200

Ans: d
60) What will be the value of variable LEN when the following code is submitted? Date temp; A=I was Bond, A real Bond; LEN=SUBSTR(A,6,4); Run; a) b) c) d) 4 23 1 200

Ans: b Note: Whenever a variable is created by assigning the value returned by the SCAN function, Its length is always $200 ( If it is not set explicitly using length statement). Similarly when a variable is created by assigning the value returned by the SUBSTR function, Its length is same as the source string no matter how many character did you cut from the original string. TRANWRD and COMPBL are the other two functions which return the value of length 200.
61) How many observations will be there in output dataset temp? data temp; x=4; if x=5 then do; y=2; output; end; run; a) b) c) d) 1 2 0 3

Ans: c
62) Which variables will be present in dataset FINAL; data FINAL; set TRY1(KEEP= NUM1 NUM2 NUM3 NUM4) TRY2(KEEP= NUM5 NUM6 NUM7 NUM8); DROP NUM2 NUM4 NUM7; KEEP NUM1 NUM3;

17

RUN; A) B) C) D) NUM1 NUM3 NUM5 NUM6 NUM8. NUM1 NUM3; Syntax Error. Warning in the log.

Ans:b
63) A dataset SEX_______CITYCODE__________JOB M NY WER F NY WER M WD RES M WD RES M SD ED M WF ED What will be the correct code to get a cross frequency table as following?
The FREQ Procedure Table of SEX by CITYCODE SEX CITYCODE

Frequency Percent Row Pct Col Pct NY SD WD WF Total F 1 0 1 0 2 16.67 0.00 16.67 0.00 33.33 50.00 0.00 50.00 0.00 50.00 0.00 50.00 0.00 M 1 1 1 1 4 16.67 16.67 16.67 16.67 66.67 25.00 25.00 25.00 25.00 50.00 100.00 50.00 100.00 Total 2 1 2 1 6 33.33 16.67 33.33

16.67 100.00

a) b) c) d)

PROC FREQ DATA=A; TABLES SEX*CITYCODE; RUN; PROC FREQ DATA=A; TABLES SEX CITYCODE; RUN; PROC FREQ DATA=A; TABLES SEX, CITYCODE; RUN; PROC FREQ DATA=A; VAR SEX CITYCODE; RUN;

Ans: a Suggestions: 18

1.) Please Go Through Programming Essentials I And II before appearing In Exam. 2.) Practice well to differentiate between the cases of Syntax Error and Missing value. This will help you achieving good score in Handling Errors. Jan30-06 1. Raw data file given is ----|---01012000 data temp; infile 'file'; input date mmddyy10.; if date='01012000'd then EVENT='January 1st'. run; What is the value of EVENT in the dataset? a) January 1st b) '' (blank character value) c) no value as there is a syntax error in the datastep d) 01012000 ans c) as date constant uses ddmmmyyyy format i.e. date='01jan2000'd is the correct option here. 2. Array name related conceptual question 3. data temp; infile 'file'; input relation $ @; if relation='children' then input sex $54; else if relation='parent' then input profession $; input Age; run; how many records from infile will be read for a record in the dataset? a) 0

19

b) 1 c) 2 d) 3 ans 1 4. data temp; infile 'file'; retain address {12}; array address {12} address1-address12; run; how many observations?? a) 0 b) 1 c) 2 d) 3 ans a (syntax error - error in retain statement) 5. proc sort data=temp; by style; run; proc print data=temp; <insert statements here for the exhibit shown> run; Style Condo Bedrooms 50.158 Baths 12.225 Ranch Bedrooms 25.212 Baths 2.22 Split Bedrooms 124.55 Baths 120.22 a) b) ans a 6. What should be the code for the exhibit shown below: proc report data=temp; columns style bedrooms baths price; id style; by style; var style bedrooms baths price; id style

20

<insert code>; run; (Dataset is also shown and the values of price in the exhibit is not mean) Style Condo Bedrooms Baths Ranch Bedrooms Baths Split Bedrooms 124.55 Baths 120.22 Price 50.158 12.225 25.212 2.22

a) define style/display width=9; define price/sum width=9; b) define style/display width=9; define price/mean width=9; ans a 7. which statement creates grandtotal of cost? a) grandtot=grandtot+cost; b) retain grandtot=0; grandtot=sum(grandtot, cost); c) retain grandtot; ans b 8. Theory question related to SUM statement (not sum function) which is true for the SUM statement? a) SUM function is used in conjunction b) it creates an accumulator variable 9. Question on PROC REPORT which uses mean of Price (given in the exhibit)verify the values of price in dataset with the exhibit to identify the statistics used. 10. which option limits the decimals for standard deviation in the proc below to 2 decimals proc means data=temp mean std max; run; a) maxdec=2 b) format std 7.2 c) maxdec= 7.2 ans a

21

11. data temp; jobcode='FA' jobcategory='1'; jobcode=jobcode||jobcategory; run; what wud be value of jobcode ans FA 12. data temp; str='London, England'; str2=substr(str, 1, 8); str3=str2||'England'; run; value of str3? a) London, England b) England c) London, England ans a 13. Usage of Display option in DEFINE statement in PROC REPORT. 14. Input file has ----|-$1,120 data temp; infile 'file'; input @1 price; run; value of price? a) 1120 b) $1,120 c) 2 d) .(missing) ans d

Base qns

22

Q1 first 0.0713 second 0.0715 third 0.0773 Dataset Bank has above data. What is the output of following code data newbank; do i=1 to 3; set banks; cost+5000; end; run; Ans: 1 observation n 4 variables Q2 There are 5000 observations in NEW dataset. How many observations would be processed by following codes? options obs=500; proc print data=new (firstobs=100); run; options obs=max; proc means data=new (firstobs=500); run; Ans: 401 obs in Proc Print 4501 obs in Proc Means Q3

1. Which of the following statements is true when SAS encounters a syntax error in a DATA step? a. The SAS log contains an explanation of the error. b. The DATA step continues to execute and the resulting data set is complete. c. The DATA step stops executing at the point of the error and the resulting data set contains observations up to that point. d. A note appears in the SAS log indicating that the incorrect statement was saved to a SAS data set for further examination.

Q4

23

1. The following SAS program is submitted:


2. data work.accounting; 3. length jobcode $ 12; 4. set work.department; run;

The Work.Department SAS data set contains a character variable named jobcode with a length of 5. Which of the following is the length of the variable jobcode in the output data set? a. 5 b. 8 c. 12 d. The value cannot be determined because the program fails to execute due to syntax errors.
Q5 What is the value stored in NUM after this code is submitted? data n2; input num 6.; datalines; $1,234.5 ; run; Ans: . Q6 What is the value stored in variable THIRD after the following program is submitted? data n3; first='FA'; second='1'; third=first||second; run; Ans: FA1 Q7

1. Which one of the following statements is true when SAS encounters a data error? a. The execution phase is stopped, and a system abend occurs. b. A missing value is assigned to the appropriate variable, and execution continues. c. The execution phase is stopped, and a SAS data set is created with zero observations.

24

d. A missing value is assigned to the appropriate variable, and execution stops at that point.
Q8 How many records are there in the dataset when following code is submitted? data n4; input name $ age sales; datalines; steve randall 45 5000 david shepherd 57 6000 russell tiffin 38 7000 simon taufel 32 4000 ; if age le 50; run; Ans 4 observations 3 variables Q9 What is the value stored in NDATE when this code is executed? data n5; dy=23; mn=3; yr=2000; ndate=mdy(mn,dy,yr); run; Ans 14692 (SAS equivalent of 23-MAR-2000) Q10. What will be the value printed when following FORMAT is applied to Marks of 50.5. Dataset is SCORES, var is Marks which holds marks. proc format; value rslt 1-50='Fail' 51-100='Pass'; run; proc print data=scores; format mark rslt.; run;

Ans : 50.5

25

SAS Base Programming for SAS 9

Item 1
The following program is submitted.
data WORK.TEST; input Name $ Age; datalines; John +35 ; run;

Which values are stored in the output data set?


A. B. C. D. E. F. G. H. I. Name John Name John Name (missing value) Age 35 Age (missing value) Age (missing value) ---------------------

---------------------

---------------------

J.

The DATA step fails execution due to data errors. correct_answer = "A"

Item 2
Given the SAS data set WORK.ONE:
Id --182 190 250 720 Id --182 623 720 Char1 ----M N O P Char2 ----Q R S

and the SAS data set WORK.TWO:

The following program is submitted:


data WORK.BOTH; merge WORK.ONE WORK.TWO; by Id; run;

What is the first observation in the SAS data set WORK.BOTH?

26

A. B. C.

Id --182 Id --182 Id --182 Id --720

Char1 ----M Char1 -----

Char2 -----

D.
E. F. G. Char2 ----Q Char1 ----M Char1 ----P Char2 ----Q Char2 ----S

H.
I. J. K.

L.
M. N. O.

P. correct_answer = "C"

Item 3
Given the text file COLORS.TXT:
----+----1----+----2----+---RED BLUE CYAN GRAY ORANGE INDIGO WHITE BROWN YELLOW PURPLE FUCSIA PINK GREEN VIOLET BLACK MAGENTA

The following SAS program is submitted:


data WORK.COLORS; infile 'COLORS.TXT'; input @1 Var1 $ @8 Var2 $ @; input @1 Var3 $ @8 Var4 $ @; run;

What will the data set WORK.COLORS contain?


A. B. C. D. E. F. Var1 -----RED BLUE CYAN GRAY Var1 -----RED CYAN Var2 -----ORANGE INDIGO WHITE BROWN Var2 -----ORANGE WHITE Var3 -----RED BLUE CYAN GRAY Var3 -----BLUE GRAY Var4 -----ORANGE INDIGO WHITE BROWN Var4 -----INDIGO BROWN

G.
H. I. J. K.

27

L.
M. N. O. P. Var1 -----RED BLUE Var1 -----RED BLUE CYAN GRAY Var2 -----ORANGE INDIGO Var2 -----ORANGE INDIGO WHITE BROWN Var3 -----YELLOW PURPLE Var3 -----YELLOW PURPLE FUCSIA PINK Var4 -----GREEN VIOLET Var4 -----GREEN VIOLET BLACK MAGENTA

Q.
R. S. T. U. V. W.

X. correct_answer = "A"

Item 4
Given the SAS data set WORK.INPUT:
Var1 -----A A B C A Var2 ------one two three four five

The following SAS program is submitted:


data WORK.ONE WORK.TWO; set WORK.INPUT; if Var1='A' then output WORK.ONE; output; run;

How many observations will be in data set WORK.ONE? Enter your numeric answer. Do not add leading or trailing spaces to your answer.

correct_answer = "8"

Item 5
The following SAS program is submitted:
data WORK.LOOP; X = 0;

28

do Index = 1 to 5 X = Index; end; run;

by

2;

Upon completion of execution, what are the values of the variables X and Index in the SAS data set named WORK.LOOP? A. X = 3, Index = 5 B. C. D. X = 5, Index = 5 X = 5, Index = 6 X = 5, Index = 7 correct_answer = "D"

Item 6
The following SAS program is submitted:
proc format; value score run; 1 - 50 = 'Fail' = 'Pass'; 51 - 100

Which one of the following PRINT procedure steps correctly applies the format?
A. B. C. D. proc print data = SASUSER.CLASS; var test; format test score; run; proc print data = SASUSER.CLASS; var test; format test score.; run; proc print data = SASUSER.CLASS format = score; var test; run; proc print data = SASUSER.CLASS format = score.; var test; run;

E.
F. G. H. I.

J.
K. L. M.

N.
O. P. Q.

R. correct_answer = "B"

Item 7
This item will ask you to provide a line of missing code;

29

The SAS data set WORK.INPUT contains 10 observations, and includes the numeric variable Cost. The following SAS program is submitted to accumulate the total value of Cost for the 10 observations:
data WORK.TOTAL; set WORK.INPUT; <insert code here> Total=Total+Cost; run;

Which statement correctly completes the program?


A. B. C. D. keep Total; retain Total 0; Total = 0; If _N_= 1 then Total = 0;

correct_answer = "B"

Item 8
This question will ask you to provide a line of missing code. Given the following data set WORK.SALES:
SalesID ------W6790 W7693 W1387 data WORK.QTR1; set WORK.SALES; array month{3} SalesJan FebSales MarchAmt; <insert code here> run; SalesJan -------50 25 . FebSales -------400 100 300 MarchAmt -------350 125 250

The following SAS program is submitted:

Which statement should be inserted to produce the following output?


SalesID ------W6790 W7693 W1387 SalesJan -------50 25 . FebSales -------400 100 300 MarchAmt -------350 125 250 Qtr1 ---800 250 550

A. B. C. D.

Qtr1 = sum(of month{_ALL_}); Qtr1 = month{1} + month{2} + month{3}; Qtr1 = sum(of month{*}); Qtr1 = sum(of month{3}); correct_answer = "C" 30

Item 9
Given the following SAS error log
44 45 46 47 48 data WORK.OUTPUT; set SASHELP.CLASS; BMI=(Weight*703)/Height**2; where bmi ge 20; run;

ERROR: Variable bmi is not on file SASHELP.CLASS.

What change to the program will correct the error? A. Replace the WHERE statement with an IF statement B. C. D. Change the ** in the BMI formula to a single * Change bmi to BMI in the WHERE statement Add a (Keep=BMI) option to the SET statement correct_answer = "A"

Item 10
The following SAS program is submitted:
data WORK.TEMP; Char1='0123456789'; Char2=substr(Char1,3,4); run;

What is the value of Char2? A. 23 B. C. D. 34 345 2345 correct_answer = "D"

31

You might also like