The following is a list of questions that can help you to crack Base SAS certification exam.
Previous Part : Part 1 : SAS Base Certification Questions and Answers
Q11. Which one of the following SAS statements renames two variables?
A. set work.dept1 work.dept2(rename = (jcode = jobcode) (sal = salary));
B. set work.dept1 work.dept2(rename = (jcode = jobcode sal = salary));
C. set work.dept1 work.dept2(rename = jcode = jobcode sal = salary);
D. set work.dept1 work.dept2(rename = (jcode jobcode) (sal salary));
Answer: B. The syntax for RENAME is as follows :
RENAME=(old-name-1=new-name-1 old-name-2=new-name-2. . . old-name-n=new-name-n)
Q12. A raw data record is shown below:
07Jan2002
Which one of the following informats would read this value and store it as a SAS date value?
A. date9.
B. ddmonyy9.
C. ddMMMyy9.
D. ddmmmyyyy9.
Answer : A
Q13. What does data _null_ mean?
data _null_ ;
This statement produces:
A. no SAS dataset
B. a SAS dataset named null
C. a SAS dataset named _null_
D. the largest possible dataset
Answer : A. The data _null_ does not produce a dataset.
It is used mainly for the following purposes :
1. To create macro variables with call symput
2. To create customized reports with PUT statements writing to external files.
Previous Part : Part 1 : SAS Base Certification Questions and Answers
Q11. Which one of the following SAS statements renames two variables?
A. set work.dept1 work.dept2(rename = (jcode = jobcode) (sal = salary));
B. set work.dept1 work.dept2(rename = (jcode = jobcode sal = salary));
C. set work.dept1 work.dept2(rename = jcode = jobcode sal = salary);
D. set work.dept1 work.dept2(rename = (jcode jobcode) (sal salary));
Answer: B. The syntax for RENAME is as follows :
RENAME=(old-name-1=new-name-1 old-name-2=new-name-2. . . old-name-n=new-name-n)
Q12. A raw data record is shown below:
07Jan2002
Which one of the following informats would read this value and store it as a SAS date value?
A. date9.
B. ddmonyy9.
C. ddMMMyy9.
D. ddmmmyyyy9.
Answer : A
Q13. What does data _null_ mean?
data _null_ ;
This statement produces:
A. no SAS dataset
B. a SAS dataset named null
C. a SAS dataset named _null_
D. the largest possible dataset
Answer : A. The data _null_ does not produce a dataset.
It is used mainly for the following purposes :
1. To create macro variables with call symput
2. To create customized reports with PUT statements writing to external files.
Q14. The following SAS program is submitted:
data _null_;
set old (keep = prod sales1 sales2);
file 'file-specification';
put sales1 sales2;
run;
Which one of the following default delimiters separates the fields in the raw data file created?
A. : (colon)
B. (space)
C. , (comma)
D. ; (semicolon)
Answer : B. Since no delimiter is specified at the end of the "file", the default delimiter space will be used.
Q15. Which one of the following statements is true regarding the name of a SAS array?
A. It is saved with the data set.
B. It can be used in procedures.
C. It exists only for the duration of the DATA step.
D. It can be the same as the name of a variable in the data set.
A. It is saved with the data set.
B. It can be used in procedures.
C. It exists only for the duration of the DATA step.
D. It can be the same as the name of a variable in the data set.
Answer : C.
Q16. The SASDATA.BANKS data set has five observations when the following SAS program is submitted:
libname sasdata 'SAS-data-library';
data allobs;
set sasdata.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
How many observations will the ALLOBS data set contain?
A. 5
B. 15
C. 20
D. 25
Answer : D. Banks has 5 observations and then the do loop outputs for (20/5 + 1) times. Therefore 5*(20/5 + 1) = 25 is the observation count .
Q17. The following SAS SORT procedure step generates an output data set:
proc sort data = sasuser.houses out = report;
by style;
run;
In which library is the output data set stored?
A.WORK
B.REPORT.
C.HOUSES
D.SASUSER
Answer : A. If library name is not specified then the data will be stored in temporary dataset i.e. WORK.
Q18. The SAS data set named WORK.TEST is listed below:
Which one of the following SAS programs created this data set?
A.
data work.test;
capacity = 150;
if 100 le capacity le 200 then
airplanetype = 'Large' and staff = 10;
else airplanetype = 'Small' and staff = 5;
run;
B.
data work.test;
capacity = 150;
if 100 le capacity le 200 then
do;
airplanetype = 'Large';
staff = 10;
end;
else
do;
airplanetype = 'Small';
staff = 5;
end;
run;
C.
data work.test;
capacity = 150;
if 100 le capacity le 200 then
do;
airplanetype = 'Large';
staff = 10;
else
do;
airplanetype = 'Small';
staff = 5;
end;
run;
D.
data work.test;
capacity = 150;
if 100 le capacity le 200 then;
airplanetype = 'Small';
staff = 5;
else;
airplanetype = 'Large';
staff = 10;
run;
Answer : B. The problem with the options A,C and D is highlighted below in bold.
A. data work.test;
capacity = 150;
if 100 le capacity le 200 then
airplanetype = 'Large' and staff = 10;
else airplanetype = 'Small' and staff = 5;
run;
Log : NOTE: Variable staff is uninitialized.
capacity = 150;
if 100 le capacity le 200 then
do;
airplanetype = 'Large';
staff = 10;
else /*end missing for if do loop*/
do;
airplanetype = 'Small';
staff = 5;
end;
run;
Log : ERROR 117-185: There was 1 unclosed DO block.
NOTE: The SAS System stopped processing this step because of errors.
D. data work.test;
capacity = 150;
if 100 le capacity le 200 then;
airplanetype = 'Small';
staff = 5;
else; /* there is no if associated with this else */
airplanetype = 'Large';
staff = 10;
run;
Log : ERROR 160-185: No matching IF-THEN clause
Q19. The following SAS program is submitted:
data work.flights;
destination = 'CPH';
select(destination);
when('LHR') city = 'London';
when('CPH') city = 'Copenhagen';
otherwise;
end;
run;
Which one of the following is the value of the CITY variable?
A. London
B. Copenh
C. Copenhagen
D. ' ' (missing character value)
data work.flights;
destination = 'CPH';
select(destination);
when('LHR') city = 'London';
when('CPH') city = 'Copenhagen';
otherwise;
end;
run;
Which one of the following is the value of the CITY variable?
A. London
B. Copenh
C. Copenhagen
D. ' ' (missing character value)
Answer : B.
Notice that the LENGTH statement in the SELECT group has not been specified. Remember that without the LENGTH statement, values for Group might be truncated, as the first value for Group (London) is not the longest possible value.
city = 'London' - It contains 6 characters.
'Copenhagen' will be truncated to 6 characters i..e Copenh.
Notice that the LENGTH statement in the SELECT group has not been specified. Remember that without the LENGTH statement, values for Group might be truncated, as the first value for Group (London) is not the longest possible value.
city = 'London' - It contains 6 characters.
'Copenhagen' will be truncated to 6 characters i..e Copenh.
Q20. A raw data file is listed below:
--------10-------20-------30
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
The following SAS program is submitted using the raw data file as input:
data work.homework;
infile 'file-specification';
input name $ age height;
if age LE 10;
run;
How many observations will the WORK.HOMEWORK data set contain?
A. 0
B. 2
C. 3
D. No data set is created as the program fails to execute due to errors.
--------10-------20-------30
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
The following SAS program is submitted using the raw data file as input:
data work.homework;
infile 'file-specification';
input name $ age height;
if age LE 10;
run;
How many observations will the WORK.HOMEWORK data set contain?
A. 0
B. 2
C. 3
D. No data set is created as the program fails to execute due to errors.
Answer : C. The data set homework will have missing values under the age variable. The name has a blank in it so we need to use the & list modifier to read the data, also when using this we have to make sure that the data are at least two spaces apart.
As SAS considers missing values smaller than 10 in age variable so it has included all the three observation in the data set.
The corrected code is as follows:
Data homewo;
input fname$ lname $ age height;
if age LE 10;
datalines;
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
;
run
Prev Part : Part 1 : SAS Base Certification Questions and Answers
Next Part : Part 3 : SAS Base Certification Questions and Answers
As SAS considers missing values smaller than 10 in age variable so it has included all the three observation in the data set.
The corrected code is as follows:
Data homewo;
input fname$ lname $ age height;
if age LE 10;
datalines;
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
;
run
Prev Part : Part 1 : SAS Base Certification Questions and Answers
Next Part : Part 3 : SAS Base Certification Questions and Answers
This was really helpful.
ReplyDeleteThanks for sharing!
Thanks so much for all the nice formatted sample questions and detailed answers.
ReplyDeletevery helpful questions
ReplyDeletevery helpful sir. good job.
ReplyDeleteReally appreciate the good work!
ReplyDeleteThank you so much for sharing.
ReplyDeleteC'est vraiment gentil. Merci
ReplyDeleteQuestion 20 is the trickiest one... nice one.. An examinee will be tempted to quickly answer as '2'. Good one
ReplyDeleteq 19 i did'nt get. can any help me?
ReplyDeletewhat does it mean it is base code with sql or only base sas code