Practice Questions 3
Practice Questions 3
data work.total;
set work.salary(keep = department wagerate);
by department;
if first.department then payroll = 0;
payroll + wagerate;
if last.department;
run;
data test;
set sasuser.employees;
if 2 le years_service le 10 then
amount = 1000;
else if years_service gt 10 then
amount = 2000;
else
amount = 0;
amount_per_year = years_service / amount;
run;
Q3. The contents of the raw data file NAMENUM are listed
below:
--------10-------20-------30
Joe xx
variable
var
1variable
var1
#var
_variable#
A. 0
B. 1
C. 3
D. 6
dta work.il_corn;
set corn.state_data;
if state = 'Illinois';
run;
The keyword "data" is misspelled above. What happens to
this program during the compilation phase assuming "corn"
is a valid libref?
A. 2
B. 3
C. 4
D. None of the above
data work.accounting;
set work.dept1 work.dept2;
run;
A. 5
B. 7
C. 8
D. 12
A. no SAS dataset
B. a SAS dataset named null
C. a SAS dataset named _null_
D. the largest possible dataset
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)
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
A.WORK
B.REPORT.
C.HOUSES
D.SASUSER
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;
data work.flights;
destination = 'CPH';
select(destination);
when('LHR') city = 'London';
when('CPH') city = 'Copenhagen';
otherwise;
end;
run;
data work.one;
x = 3;
y = 2;
z = x ** y;
run;
A. amount word
5 DOG
B. amount word
5 CAT
C. amount word
7 DOG
D. amount word
7 ' ' (missing character value)
data work.report;
set work.sales_info;
if qtr(sales_date) ge 3;
run;
data work.empdata;
merge work.employee work.salary;
by fname;
run;
WORK.EMPLOYEE
fname age
Bruce 30
Dan 40
Dan 25000
WORK.SALARY
fname salary
Bruce 25000
Bruce 35000
data work.empdata;
merge work.employee work.salary;
by fname;
totsal + salary;
run;
How many variables are output to the WORK.EMPDATA
data set?
A. 3
B. 4
C. 5
D. No variables are output to the data set as the program
fails to execute due to errors.
run;
Which one of the following IF statements writes the last
observation to the output data set?
A. if end = 0;
B. if eof = 0;
C. if end = 1;
D. if eof = 1;
Q33. In the following SAS program, the input data files are
sorted by the NAMES variable:
data emplsal;
merge employee (in=ine) salary(in=ins);
by name;
if ine and ins;
run;
data work.test;
Title = 'A Tale of Two Cities, Charles J. Dickens';
Word = scan(title,3,',');
run;
IDNumber Expenses
2542 100.00
3612 133.15
2198 234.34
2198 111.12
run;
A. by Expenses IDNumber;
B. by IDNumber Expenses;
C. by ascending (IDNumber Expenses);
D. by ascending IDNumber ascending Expenses;