Thursday, October 4, 2012

SAS Interview questions 2



1. The following SAS program is submitted:
libname sasdata 'SAS-data-library';
data test;
set sasdata.chemists (keep = job_code);
if job_code = 'chem3'
then description = 'Senior Chemist';
run;
The variable JOB_CODE is a character variable with a length of 6 bytes.
Which one of the following is the length of the variable DESCRIPTION in the output data set?
A. 6 bytes
B. 8 bytes
C. 14 bytes
D. 200 bytes
Ans: c
2. The following SAS program is submitted:
data work.accounting;
set work.dept1 work.dept2;
run;
A character variable named JOBCODE is contained in both the WORK.DEPT1 and WORK.DEPT2 SAS data sets. The variable
JOBCODE has a length of 5 in the WORK.DEPT1 data set and a length of 7 in the WORK.DEPT2 data set.
Which one of the following is the length of the variable JOBCODE in the output data set?
A. 5
B. 7
C. 8
D. 12
Ans: a
3. The following SAS DATA step is submitted:
data work.accounting;
set work.department;
length jobcode $ 12;
run;
The WORK.DEPARTMENT SAS data set contains a character variable named JOBCODE with a length of 5.
Which one of the following is the length of the variable JOBCODE in the output data set?
A. 5
B. 8
C. 12
D. The length can not be determined as the program fails to execute
due to errors.
Ans: a
4. 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));
Ans: b
5. The following SAS program is submitted:
data work.company;
set work.dept1(keep = jobcode)
work.dept2(rename = (jcode = jobcode));
run;
Which one of the following is the result?
A. The variable JCODE is written to the output data set.
B. The variable JOBCODE is written to the output data set.
C. Neither variable JCODE nor JOBCODE is written to the output data set.
D. The program fails to execute due to errors.
Ans: b
6. The following SAS program is submitted:
data work.passengers;
if OrigPassengers = . then
OrigPassengers = 100;
TransPassengers = 100;
OrigPassengers = .;
NonPaying = 10;
TotalPassengers = sum (OrigPassengers, TransPassengers);
run;
Which one of the following is the value of the TOTALPASSENGERS variable in the output data set?
A. 100
B. 110
C. 200
D. . (missing numeric value)
Ans: a
7. The following SAS program is submitted:
data work.staff;
JobCategory = 'FA';
JobLevel = '1';
JobCategory = JobCategory || JobLevel;
run;
Which one of the following is the value of the variable JOBCATEGORY in the output
data set?
A. FA
B. FA1
C. FA 1
D. ' ' (missing character value)
Ans: a
8. The following SAS program is submitted:
data work.one;
x = 3;
y = 2;
z = x ** y;
run;
Which one of the following is the value of the variable Z in the output data set?
A. 6
B. 9
C. . (missing numeric value)
D. The program fails to execute due to errors.
Ans: b
9. The SAS data set named WORK.TEST is listed below:
capacity airplanetype staff
150 Large 10
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;
Ans: b
10.   The following SAS program is submitted:
data work.flights;
destination = 'cph';
select(destination);
when('LHR') city = 'London';
when('CPH') city = 'Copenhagen';
otherwise city = 'Other';
end;
run;
Which one of the following is the value of the CITY variable?
A. Other
B. Copenh
C. Copenhagen
D. ' ' (missing character value)
Ans: a
11.   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)
Ans: b
12.   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 word
7 FOUR
B. amount word
7 SEVEN
C. amount word
4 FOUR
D. amount word
4 ' ' (missing character value)
Ans: a
13.   The SAS data set EMPLOYEE_INFO is listed below:
IDNumber Expenses
2542 100.00
3612 133.15
2198 234.34
2198 111.12
The following SAS program is submitted:
proc sort data = employee_info;

run;
Which one of the following BY statements completes the program and sorts the data sequentially by descending expense values within
each descending IDNUMBER value?
A. by descending IDNumber Expenses;
B. by (IDNumber Expenses) descending;
C. by IDNumber descending Expenses descending;
D. by descending IDNumber descending Expenses;
Ans: d
14.   The SAS data set QTR1_REVENUE is listed below:
destination revenue
YYZ 53634
FRA 62129
FRA 75962
RDU 76254
YYZ 82174
The following SAS program is submitted:
proc sort data = qtr1_revenue;
by destination descending revenue;
run;
Which one of the following represents the first observation in the output data set?
A. destination revenue
YYZ 82174
B. destination revenue
YYZ 53634
C. destination revenue
FRA 62129
D. destination revenue
FRA 75962
Ans: d
15.   The following SAS program is submitted:
libname company 'SAS-data-library';
proc sort data = company.payroll;
by EmployeeIDNumber;
run;
Write access has been granted to the COMPANY library.
Which one of the following represents how the observations are sorted?
A. COMPANY.PAYROLL is recreated in sorted order by EmployeeIDNumber.
B. COMPANY.PAYROLL is stored in original order, and a new data set PAYROLL is created in sorted order by
EmployeeIDNumber.
C. COMPANY.PAYROLL is stored in original order, and a new data set COMPANY.PAYROLLSORTED is created in sorted order
by EmployeeIDNumber.
D. COMPANY.PAYROLL is recreated in sorted order by EmployeeIDNumber, and a new data set PAYROLL is created in sorted
order by EmployeeIDNumber.
Ans: a
16.   The SAS data set EMPLOYEE_INFO is listed below:
IDNumber Expenses
2542 100.00
3612 133.15
2198 234.34
2198 111.12
The following SAS program is submitted:
proc sort data = employee_info;

run;
Which one of the following BY statements completes the program and sorts the data sequentially by ascending expense values within
each ascending IDNUMBER value?
A. by Expenses IDNumber;
B. by IDNumber Expenses;
C. by ascending (IDNumber Expenses);
D. by ascending IDNumber ascending Expenses;
Ans: d
17.   The SAS data set WORK.AWARDS is listed below:
fname points
Amy 2
Amy 1
Gerard 3
Wang 3
Wang 1
Wang 2
The following SAS program is submitted:
proc sort data = work.awards;
by descending fname points;
run;
Which one of the following represents how the observations are sorted?
A. Wang 3
Gerard 3
Wang 2
Amy 2
Wang 1
Amy 1
B. Wang 3
Wang 2
Wang 1
Gerard 3
Amy 2
Amy 1
C. Wang 3
Wang 1
Wang 2
Gerard 3
Amy 2
Amy 1
D. Wang 1
Wang 2
Wang 3
Gerard 3
Amy 1
Amy 2
Ans:  b
18.   The observations in the SAS data set WORK.TEST are ordered by the values of the variable NAME.
The following SAS program is submitted:
proc sort data = work.test out = work.testsorted;
by name;
run;
Which one of the following is the result of the SAS program?
A. The data set WORK.TEST is stored in ascending order by values of the NAME variable.
B. The data set WORK.TEST is stored in descending order by values of the NAME variable.
C. The data set WORK.TESTSORTED is stored in ascending order by values of the NAME variable.
D. The data set WORK.TESTSORTED is stored in descending order by values of the NAME variable.
Ans: c
19.   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.
Ans: c
20.   The following SAS program is submitted:
data stats;
set revenue;
array weekly{5} mon tue wed thu fri;

total = weekly{i} * .25;
output;
end;
run;
Which one of the following DO statements completes the program and processes the elements of the WEEKLY array?
A. do i = 1 to 5;
B. do weekly{i} = 1 to 5;
C. do i = mon tue wed thu fri;
D. A DO loop cannot be used because the variables referenced do not end in a digit.
Ans: a
21.   The following SAS program is submitted:
data work.test;
array agents{4} $ 12 sales1 - sales4;
run;
Which one of the following represents the variables that are contained in the output data set?
A. SALES1, SALES2, SALES3, SALES4
B. AGENTS1, AGENTS2, AGENTS3, AGENTS4
C. None, the DATA step fails because the ARRAY statement can reference only numeric data.
D. None, the DATA step fails because the ARRAY statement can reference only pre-existing variables.
Ans: a
22.   The following SAS program is submitted:
data work.test;
set work.staff (keep = jansales febsales marsales);
array diff_sales{3} difsales1 - difsales3;
array monthly{3} jansales febsales marsales;
run;
Which one of the following represents the new variables that are created?
A. JANSALES, FEBSALES and MARSALES
B. MONTHLY1, MONTHLY2 and MONTHLY3
C. DIFSALES1, DIFSALES2 and DIFSALES3
D. DIFF_SALES1, DIFF_SALES2 and DIFF_SALES3
Ans: c
23.   On which portion(s) of a SAS data set does the PRINT procedure report?
A. the data portion only
B. the descriptor portion only
C. the descriptor portion and the data portion
D. neither the data portion nor the descriptor portion
Ans: a
24.   Which one of the following SAS procedures displays the data portion of a SAS data set?
A. PRINT
B. FSLIST
C. CONTENTS
D. DATASETS
Ans: a
25.   The following SAS program is submitted:
proc datasets lib = sasuser;
contents data = class varnum;
quit;
Which one of the following is the purpose of the VARNUM option?
A. to print a list of variable names
B. to print the total number of variables
C. to print a list of the variables in alphabetic order
D. to print a list of the variables in the order they were created
Ans: d
26.   The following SAS program is submitted:
proc contents data = sasuser.airplanes;
run;
Which one of the following is produced as output?
A. the data portion of every data set in the SASUSER library
B. the data portion of the data set SASUSER.AIRPLANES only
C. the descriptor portion of every data set in the SASUSER library
D. the descriptor portion of the data set SASUSER.AIRPLANES only
Ans: d
27.   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.
Ans: c
28.   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
Ans: d
29.   The SAS data set named COMPANY.PRICES is listed below:
COMPANY.PRICES
prodid price producttype sales returns
K12S 5.10 NETWORK 15 2
B132S 2.34 HARDWARE 300 10
R18KY2 1.29 SOFTWARE 25 5
3KL8BY 6.37 HARDWARE 125 15
DY65DW 5.60 HARDWARE 45 5
DGTY23 4.55 HARDWARE 67 2
The following SAS program is submitted:
libname company 'SAS-data-library';
data hware inter soft;
set company.prices (keep = producttype price);
if price le 5.00;
if producttype = 'HARDWARE' then output HWARE;
else if producttype = 'NETWORK' then output INTER;
else if producttype = 'SOFTWARE' then output SOFT;
run;
How many observations does the HWARE data set contain?
A. 0
B. 2
C. 4
D. 6
Ans: b
30.   The following SAS program is submitted:
data allobs;
set sasdata.origin (firstobs = 75 obs = 499);
run;
The SAS data set SASDATA.ORIGIN contains 1000 observations.
How many observations does the ALLOBS data set contain?
A. 424
B. 425
C. 499
D. 1000
Ans:  b

No comments: