Loading...

Interview Questions on Base SAS

1.)The following SAS program is submitted:

data work.new;
length word $7;
amount = 7;
if amount = 5 then word = 'CAT';
else if amount = 7 then word = 'DOG';
else word = 'NONE!!!';
amount = 5;
run;

Which one of the following represents the values of the AMOUNT and WORD variables?

A. amount word
5 DOG

B. amount word
5 CAT

C. amount word
7 DOG

D. amount word
7 ' ' (missing character value)

Answer : A. When SAS reads in the iterations in sequence, it first writes 7 to the variable 'amount' in PDV. Then it reads through the condition and writes 'DOG' for variable 'word' in PDV. Then it again encounters the value 5 and writes to 'Amount' in PDV.

2.) The following SAS program is submitted:
data _null_;
set old;
put sales1 sales2;
run;
Where is the output written?

A. the SAS log
B. the raw data file that was opened last
C. the SAS output window or an output file
D. the data set mentioned in the DATA statement

Answer : A.

3.) The following SAS program is submitted:

data work.report;
set work.sales_info;
if qtr(sales_date) ge 3;
run;

The SAS data set WORK.SALES_INFO has one observation for each month in the year 2000 and the variable SALES_DATE which contains a SAS date value for each of the twelve months.

How many of the original twelve observations in WORK.SALES_INFO are written to the WORK.REPORT data set?

Answer : C. The qtr (quarter) values of each of the months (July through December) 7,8,9,10,11,12 is 3,3,3,4,4,4..Therefore 6 obs are included in the final dataset.

4.) The SAS data sets WORK.EMPLOYEE and WORK.SALARY are listed below:

WORK.EMPLOYEE
fname age
Bruce 30
Dan 40
Dan 25000

WORK.SALARY
fname salary
Bruce 25000
Bruce 35000
Base SAS Interview Questions

5.) The following SAS program is submitted:

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.

Answer : B. The variables are: Fname, age, salary and totsal.
Note: Obs will not be counted here.

6.)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

7.) 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.

8.) 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.

9.) 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 they do loop outputs for (20/5 + 1) times. Therefore 5*(20/5 + 1) = 25 is the observation count.

10.) 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)

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.
VirtualNuggets 5759036453309528388

Post a Comment

  1. I have been searching for SAS interview question and answers.This blog is very useful and informative. Thanks for sharing.
    SAS Certification

    ReplyDelete

emo-but-icon

Home item

Blog Archive

Popular Posts

Random Posts

Flickr Photo