Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
56 views6 pages

SAS Test Revised

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 6

SAS Test

1. What is the difference between where and if statement?


2. At Compile Time When A SAS Data Set Is Read, What Items Are Created?
3. If You Have A Data Set That Contains 100 Variables, But You Need Only
Five Of Those, What Is The Code To Force SAS To Use Only That Variable?
4. What is the purpose of the trailing @ and the @@? How would you use them?
5. In the following SAS program, the input data files are sorted by the NAMES
variable: write the syntax of sort?

libname temp 'SAS-data-library';


data temp.sales;
merge temp.sales work.receipt;
by names;
run;
6. Which one of the following results occurs when this program is submitted?

 The program executes successfully and a temporary SAS data set is


created.
 The program executes successfully and a permanent SAS data set is
created.
 The program fails execution because the same SAS data set is referenced
for both read and write operations.
 The program fails execution because the SAS data sets on the MERGE
statement are in two different libraries.
7. The following SAS program is submitted and reads 100 records from a raw
data file: what is the use of infile and input statements ?
data work.total;
infile 'file-specification' end = eof;
input name $ salary;
totsal + salary;
run;

8. 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;
9. The contents of two SAS data sets named EMPLOYEE and SALARY are listed
below: write a code which gives you the detailed description of data and
descriptor portion for a data set in sas ?
data emplsal;
merge employee (in=ine) salary(in=ins);
by name;
if ine and ins;
run;

10. How many observation are in EMPLSAL dataset?


A. 4
B. 3
c. 2
D. 1

11. Which one of the following is true of the SUM statement in a SAS DATA step
program?
o It does not retain the accumulator variable value from one iteration of the
SAS DATA step to the next.
o It adds the value of an expression to an accumulator variable and ignores
missing values.
o It is not valid with the SET, MERGE and UPDATE statements.
o It is only valid in conjunction with a SUM function.

12. SAS date values are the number of days since which date
a. Jan 1, 1900
b. Jan 1, 1950
c. Jan 1, 1960
d. Jan 1, 1970

13. An input date file has date expression in the form 10222001. Which SAS informat
should you use to read dates?
a. DATE6.
b. DATE8.
c. MMDDYY6.
d. MMDDYY8.

14. Which SAS statement repetitively executes several statements while the value of
cholesterol is greater than 200?
a. do cholesterol>200
b. do cholesterol gt 200
c. do while (cholesterol>200);
d. do while cholesterol>200;

15. If you submit the following program, which variables appear in the new data set?

Data work.cardiac(drop = age group);


Set clinic.fitness(keep = age weight group);
If group = 2 and age >40;
Run;

a. none
b. weight
c. age, group
d. age, weight, group

16. which statement identifies the name of a raw data file to be read with the fileref
products and specifies the data step read only records 1-15?
a. infile products obs 15;
b. infile products obs = 15;
c. input products obs = 15;
d. input products 1-15;

17. Suppose you run a SAS program that causes three data step errors. What is the
value of the automatic variable _error_ when the observation that contains the
third error is processed?
a. 0
b. 1
c. 2
d. 3
18. Based on the input statement in the data step below, in what order will the variables
be stored in the new data set?

Data perm.update;
Infile invent;
Input idnum $ 15-19 item $ 1-13 instock 21-22 backord 24-25;
Total = instock + backord;
Run;
a. idnum item instock baclord total
b. item idnum instock backord total
c. total idnum item instock backord
d. total item idnum instock backord
19. There are two data sets. First data set has variables name, age. Second data set has
variables name, age and date. What happens if you merge the two data sets by
variable name?
a. The values f age in the first data set overwrite the values of age in the second data
set.
b. The values of age in the second data set overwrite the values of age in the first data
set.
C. The DATA step fails because the two data sets contain same named variables that
have different values
d. The values of age in the second data set are set to missing.

20. The following SAS program is submitted.


DATA flatten;
Input jobcode $ salary name $;
Cards;
Flat1 70000 bob
Flat2 60000 joe
Flat3 30000 ann
;
Run;
Data desc;
Set flatten;
If salary > 60000then description = ‘over 60’;
Else description = ‘under60’;
Run;
What is the value of the variable description when the value of salary is 30000?

a. under 6
b. under 60
c. over 60
d. Missing character value

21. 10. The following SAS program is submitted


DATA work.inventory;
Products = 7;
Do until(products gt 6);
Products + 1;
End;
Run;
What is the value of products in the output data set?
a. 5
b. 6
c. 7
d. 8

22. The following program is submitted


Data test;
Average = mean (6, 4, ., 2);
Run;
What is the value of the variable average?
a. 0
b. 3
c. 4
d. .

23. The following SAS program is submitted.


DATA work.travel;
Do I = 1 to 6 by 2;
Trip + I;
End;
Run;
Which one of the following is the value of the variable trip in the output data set?
a. 2
b. 3
c. 9
d. 10

24. Which of the following variable names is valid?


a. 4birthdate
b. $cost
c. _items_
d. tax-rate

25. Which of the following files is a permanent SAS file?


a. SAShelp.prdsales
b. SASuser.mysales
c. profits.quarter1
d. all of the above.

26. In a data step, how can you reference a temporary SAS data set named forecast?
a. forecast
b. work.forecast
c. sales.forecast
d. both a and b

27. Which one is correct:


a. 2 + .(missing value) = 2
b. 2 + .(missing value) = .(missing value)

28. What is the difference between an informat and a format? Name three informats or
formats.
29. How do you create library in SAS ?What is the difference between temporary library
and permanent library?

30. Which option in the PROC IMPORT procedure overwrites an existing file?

A. NEW
B. OVERWRITE
C. REPLACE
D. KEEP

You might also like