SAS Base (24)

Given the following raw data records:

----|----10---|----20
Susan*12/29/1970*10
Michael**6

The following output is desired:

Obs employee bdate years
1 Susan 4015 10
2 Michael . 6

Which SAS program correctly reads in the raw data?
A.
data employees;
infile ‘file specification’ dlm=’*’;
input employee $ bdate : mmddyy10. years;
run;

B.
data employees;
infile ‘file specification’ dsd=’*’;
input employee $ bdate mmddyy10. years;
run;

C.
data employees;
infile ‘file specification’ dlm dsd;
input employee $ bdate mmddyy10. years;
run;

D.
data employees;
infile ‘file specification’ dlm=’*’ dsd;
input employee $ bdate : mmddyy10. years;
run;

Check Answer

SAS Base (2)

Given the following raw data records in TEXTFILE.TXT:

----|----10---|----20---|----30
John,FEB,13,25,14,27,Final
John,MAR,26,17,29,11,23,Current
Tina,FEB,15,18,12,13,Final
Tina,MAR,29,14,19,27,20,Current

The following output is desired:

Obs Name Month Status Week1 Week2 Week3 Week4 Week5
1 John FEB Final $13 $25 $14 $27 .
2 John MAR Current $26 $17 $29 $11 $23
3 Tina FEB Final $15 $18 $12 $13 .
4 Tina MAR Current $29 $14 $19 $27 $20

Which SAS program correctly produces the desired output?

A.
data WORK.NUMBERS;

length Name $ 4 Month $ 3 Status $ 7;

infile ‘TEXTFILE.TXT’ dsd;

input Name $ Month $;

if Month=’FEB’ then input Week1 Week2 Week3 Week4 Status $;

else if Month=’MAR’ then input Week1 Week2 Week3 Week4 Week5 Status $;

format Week1-Week5 dollar6.;

run;

proc print data=WORK.NUMBERS;

run;

B.

data WORK.NUMBERS;

length Name $ 4 Month $ 3 Status $ 7;

infile ‘TEXTFILE.TXT’ dlm=’,’ missover;

input Name $ Month $;

if Month=’FEB’ then input Week1 Week2 Week3 Week4 Status $;

else if Month=’MAR’ then input Week1 Week2 Week3 Week4 Week5 Status $;

format Week1-Week5 dollar6.;

run;

proc print data=WORK.NUMBERS;

run;

C.

data WORK.NUMBERS;

length Name $ 4 Month $ 3 Status $ 7;

infile ‘TEXTFILE.TXT’ dlm=’,’;

input Name $ Month $ @;

if Month=’FEB’ then input Week1 Week2 Week3 Week4 Status $;

else if Month=’MAR’ then input Week1 Week2 Week3 Week4 Week5 Status $;

format Week1-Week5 dollar6.;

run;

proc print data=WORK.NUMBERS;

run;

D.

data WORK.NUMBERS;

length Name $ 4 Month $ 3 Status $ 7;

infile ‘TEXTFILE.TXT’ dsd @;

input Name $ Month $;

if Month=’FEB’ then input Week1 Week2 Week3 Week4 Status $;

else if Month=’MAR’ then input Week1 Week2 Week3 Week4 Week5 Status $;

format Week1-Week5 dollar6.;

run;

proc print data=WORK.NUMBERS;

run;

Check Answer