Professional Documents
Culture Documents
Sample
Sample
set sasdata.chemists;
if jobcode = chem3 then description = Senior Chemist ;
else description = Unknown ;
run;
A value for the variable JOBCODE is listed below:
JOBCODE
CHEM3
Which one of the following values does the variable DESCRIPTION contain?
A. chem3
B. Unknown
C. Senior Chemist
D.
(missing character value)
Answer: B
Question: 6
The following SAS program is submitted;
data work.month;
date = put( 13mar2000 d,ddmmw10.);
run;
Which one of the following represents the type and length of the variable DATE i
n the output data set?
A. numeric, 8 bytes
B. numeric, 10bytes
C. character, 8 bytes
D. character, 10 bytes
Answer: D
Question: 7
The SAS data set QTR 1_REVENUE is listed below:
The following SAS program is submitted:
proc sort data = qtrl_revenue;
by destination descending revenue;
run;
Which one of the following represents the first observation in the output data s
et?
destination revenue
YYZ 53634
FRA 62129
FRA 75962
RDU 76254
YYZ 82174
A. destination revenue
YYZ 82174
B. destination revenue
YYZ 53634
C. destination revenue
FRA 62129
D. destination revenue
FRA 75962
Answer: D
Question: 8
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
Question: 9
The following SAS program is submitted and reads 100 records from a raw data fil
e:
data work.total;
infile file-specification end = eof;
input name $ salary;
totsal + salary;
<insert IF statement here>
run;
Which one of the following IF statements write the last observation to the outpu
t data set?
A. if end = 0;
B. if eof = 0;
C. if end = 1;
D. if eof = 1;
Answer: D
Question: 10
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 variable
s?
A. amount word
7 FOUR
B. amount word
7 FOUR
C. amount word
4 FOUR
D. amount word
4
Answer: A
Question: 11
Click the Exhibit button to view a listing of the SASUSER.HOUSES data set.
style price
CONDO $79,700
RANCH $68,575
SPLIT $77,983
TWOSTORY $62,550
The following SAS program is submitted:
proc report data = sasuser.houses nowd headline;
column style price;
where price lt 100000;
<insert DEFINE statement here>
define price / mean width = 9;
title;
run;
The following output is created by the REPORT procedure:
Which one of the following DEFINE statements completes the above program and pro
duces the above output?
A. define style / order width = 9;
Which one of the following SAS statements completes the program and results in a
value of Printing 750 for the DEPARTMENT variable?
A. department = trim(dept) II number;
B. department = dept II input(number,3.);
C. department = trim(dept) II put(number,3.);
D. department = input(dept,11.) II input(number,3.);
Answer: C
Question: 19
The contents of two SAS data sets named EMPLOYEE and SALARY are listed below.
EMPLOYEE SALARY
name age name salary
Bruce 30 Bruce 40000
Dan 35 Bruce 35000
Dan 37000
Dan The following SAS program is submitted:
data work.empsalary
merge work.employee (in = inemp)
work.salary (in = insal);
by name;
if inemp and insal;
run;
How many observations will the data set WORK.EMPSALARY contain?
A. 2
B. 4
C. 5
D. 6
Answer: B
Question: 20
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.
Answer: C
Question: 21
The contents of the raw data file FURNITURE are listed below:
----|----10----|----20----|----30
chair,,table
chair,couch,table
The following SAS program is submitted:
data stock;
infile furniture dsd;
input item 1 $ item2 $ item3 $;
run;
Which one of the following is the value of the variable named ITEM2 in the first
observation of the output data set?
A. table
B. table
C. (missing numeric value)
D. (missing character value)
Answer: D
Question: 22
The contents of the raw data file CALENDAR are listed below:
----|----10----|----20----|----30
01012000
The following SAS program is submitted:
data test;
infile calendar ;
input@1 date mmddyy10.;
fo
run;
What is the value of the variable PROD in the output data set?
A - 6
B - 7
C - 8
D - (missing numeric)
Answer: B
Question: 30
Given the SAS data sets EMPLOYEE and SALARY:
EMPLOYEE SALARY
Fname age name salary
Bruce 30 Bruce 25000
Dan 40 Bruce 35000
Dan 25000
The following SAS program is submitted:
data work.empdata;
<insert MERGE statement here>
by fname;
totsal + salary;
run;
Which MERGE statement correctly completes the program?
A - merge employee
salary rename = fname = name;
B - merge employee
salary rename(name = fname);
C - merge employee
salary (rename = (fname = name));
D - merge employee
salary (rename = (name = fname));
Answer: D
Question: 31
Which program displays a listing of all data sets in the SASUSER library?
A - proc contents lib = sasuser.all; run;
B - proc contents data = sasuser.all; run;
C - proc contents lib = sasuser._alI_; run;
D - proc contents data = sasuser._all_; run;
Answer: D
Question: 32
The following SAS program is submitted:
proc sort data = work.employee;
by descending fname;
proc sort data = work.salary;
by descending fname;
data work.empdata;
merge work.employee
work.salary;
by fname;
run;
Why does the program rail to execute?
A - The SORT procedures contain invalid syntax.
B - The merged data sets are not permanent SAS data sets.
C - The RUN statement was omitted alter each or the SORT procedures.
D - The data sets were not merged in the order by which they were sorted.
Answer: D
Question: 33
The following SAS program Is submittad:
data work.sales;
do year = 1 to 5;
do month=1 to 12;
x+1;
output
end;
end;
run;
How many observations are written the WORK SALES data set?
A - 0
B - 1
C - 5
D - 60
Answer: D
Question: 34
Given the following raw data record:
----I----10---I----20---I----30
son Travis,
The following output is desired:
Obs relation firstname
1 son Travis
Which SAS program correctly reads in the raw data?
A - data family ( dIm = , ); infile tile specification ; input relation $ firstname $;
run;
B - options dIm = , ; data family; infile file specification ; input relation $ firstn
ame $; run;
C - data family; infile file specification dIm = , ; input relation $ firstname $; ru
n;
D - data family; infile file specification ; input relation $ firstname $ / dim = , ;
run;
Answer: C
Values and names may be different:
Question: 35
Which ODS command closes the HTML file?
Answer: ODS HTML CLOSE;
1.) Which is the correct statement:
a.) ODS HTML FILE = file ;
b.) ODS FILE HTML = file
c.) ODS FILE = file
d.) ODS HTML = file
Answer: a
Question: 36
data temp;
set lib1.x
lib2.y;
length jobcode $12.;
run;
What would be the length of Jobcode in temp?
a.) 5
b.) 8
c.) 12
d.) Syntax Error
Answer: c
Question: 37
PROC SORT data = lib.temp out = temp2;
By subjid;
Run;
In which library temp2 is made?
a.) WORK
b.) SASUSER
c.) LIB
d.) SYNTAX ERROR
Answer: a
Question: 38
Question: 41
DATA TEMP;
MISSING CODE
RUN;
What is the correct missing code?
a.) Merge Test1 /*Test1 contains JOBCODE */
Test2(rename = (Jcode = JOBCODE));
b.) Merge Test1 /*Test1 contains JOBCODE */
Test2(rename = (JOBCODE = JCODE));
c.) Merge Test1 (rename = (Jcode = JOBCODE)) /*Test1 contains JOBCODE */
Test2;
d.) Merge Test1 /*Test1 contains JOBCODE */
Test2(rename Jcode = JOBCODE));
Answer: a
Question: 42
data temp;
test = X ;
select(test);
when( Y ) Name = Ank ;
when( X ) Name = Ankur ;
when( Z ) Name =
;
end; run;
What is the output?
a.) Ankur
b.) Ank
c.) Missing (character missing value)
d.) Ankur
Answer: Good Question. I would suggest you to try this question on your system.
The answer is b. It s because during compilation time the length of variable Name
is set as 3 (see the first case Y ) and hence even if the case X is satisfied the out
put will still be Ank.
Question: 43
data _null_;
put ankur ;
run;
Where will the ouput(ankur) be written?
a.) In Last file opened
b.) In dataset _null_
c.) Syntax error
d.) Log
Answer: d
Question: 44
What is true about _ERROR_ variable?
a.) Can be used in assignments/calculation in datastep.
b.) This variable appears in output dataset
c.) Will have values YES or NO
d.) Will have values TRUE or FALSE
Answer: a
Question: 45
What is true about array variables?
a.) They are temporary variables created in datastep.
b.) They are output in dataset.
c.) Can contain numeric and character values at same time.
d.) Cannot be used in assignment statement.
Answer: b
Question: 46
What is the system option to print TIME in OUTPUT window?
a.) DATETIME
b.) TIME
c.) DATE
d.) SECOND
Answer: c
15.) PROC Report question on difference between display and across.
16.) PROC Report question on difference between group and order.
Question: 47
DATA TEMP;
X= 13MAR2000 d;
RUN;
What is stored in x?
a.) 13MAR2000
b.) Corresponds to days from 01 Jan 1960: 14682
c.) 13/03/2000
d.) Corresponds to days from 01 Jan 1960: 135680
Answer: b (the choices mentioned in b and c points both were there. Hence I had
to calculate the number of days from 01 Jan 1960. Although a rough idea will do.
There was a digit difference between 2 options)
Question: 48
1----5----10--- (data in file asa )
03132000
data temp;
infile asa ;
input date : MMDDYY10.;
run;
What will be stored in date?
a.) 01022000
b.) 02FEB2000
c.) 14682(number of days from 1st jan 1960)
d.) 02 January
Answer: c (Note: the date is stored in dataset as SAS date)
Question: 49
data test;
n=1;
do while(n lt 6);
n+1;
end;
run;
What will be the value of n at the end of datastep?
a.) 7
b.) 5
c.) 6
d.) 8
Answer: c (Good Question again. This question will tell you that before marking
any choice think twice. Actually it comes out of do while loop when n is 6 and w
ill not execute the statement n+1;)
Question: 50
GOOD QUESTION
Proc Format;
Value ag 1-50 = less
51-100 = greater ;
Run;
Data test;
X = 50.5;
Format x ag.;
Run;
What will be the output of dataset test?
a.) less
b.) greater
c.) great
d.) 50.5
e.) systax error
Answer: d (I would suggest please try it on your PC and check for different valu
es. Whenever SAS does not find a mapping for some value in the format it print t
he value as it is.)
Question: 51
data test;
dat = 13MAR2000 d;
format dat WEEKDATE.;
run;
What will be the value of dat in output dataset?
a.) 13MAR2000
b.) Monday, March 13, 2000
c.) Mon, March 13, 2000
d.)14682 (number of days from 1st Jan 1960)
Answer: b
Question: 52
data temp;
set x;
run;
missing code
data test;
set y;
run;
What will be the missing code to reset the page number?
a.) OPTIONS PAGENO = 1;
b.) OPTIONS RESET PAGENO = 1;
c.) OPTIONS RESET PAGENUMBER = 1;
d.) OPTIONS PAGENUMBER = 1;
Answer: a
Question: 53
DATA TEMP;
Infile filename ;
Input ID $5 @;
If ID = RAMES then input Y $6 Z $10 @;
else ID = VIJAY then input R $2 @;
Input age 5.;
RUN;
How many lines are read from input file during one execution of dataset?
a.) 2
b.) 1
c.) 3
d.) 4
Answer: b (note only one execution not complete dataset)
24.) How to write comma separated file?
a.) FILE filename dsd = , ;
b.) FILE filename dlm =
dsd = , ;
c.) FILE filename dlm = , ;
d.) FILE filename csv = , ;
Answer: c
Question: 54
1----5----10----15----(file abc )
RAM,,20
RAJU,SHARMA,24
DATA temp;
Infile abc dsd;
Input FNAME $ LNAME $ AGE;
RUN;
What will be the value of LNAME for 1st observation?
a.) ,
b.) blank character value
c.) SHARMA
b).
output is written to t
output is written to t
output is written to p
output is written to p
ankur 22
data temp;
infile file ;
input name $1-10 age 15-16;
/*missing code*/
run;
What is the missing code to write ankur,22 to variable LA;
a.) LA = TRIM(name)|| , ||put(Age,2.);
b.) LA = name|| , ||put(Age,2.);
c.) LA = name|| , ||TRIM(put(Age,2.));
e.) LA = put(name)|| , ||put(Age,3.);
Answer: a
Question: 61
data temp;
merge test1(keep = ID)
test2(keep = ID NAME CLASS AGE);
by ID;
keep = ID NAME;
run;
Variables in output dataset?
A.) ID NAME
B.) NAME ID
C.) ID NAME CLASS AGE
D.) Syntax error
Answer: b
Question: 62
data a;
do X=1 to 3 ;
input ID NAME $ AGE;
end;
datalines;
01 vivek 22
02 vital 25
03 rajes 20
;
What will be the number of observations and variables in output dataset??
a.) 3 and 3
b.) 1 and 3
c.) 1 and 4
d.) 3 and 1
Answer: c
Question: 63
What informat should be used to read the date variable in the flat file having t
he values like 02NOV2003?
a) DATE9.
b) MMDDYY8.
c) MMDDYY10.
d) None
Answer: a
Question: 64
Flat file structure is as below
1----5----10
$1,120
The following code is submitted.
data temp;
infile file specification ;
input salary 5;
run;
What would be the value of SALARY in the dataset TEMP?
a) $1,120
b) 2
c). (period)
d) Blank value
Answer: b
Tip: Here the SAS goes to the 5th column and read the value. But if we specify t
he informat like SALARY 5. then there will be . In the SALARY variable. Please kee
p in mind that if there is any data error, SAS produces blank values to those va
riables(i.e . For numeric variables and blank for the character variables). SAS ne
ver stops execution when data error occurs.
Question: 65
Flat file structure is as below
1----5----10
02032000
The following code is submitted.
data temp;
infile file specification ;
input date mmddyy10.;
run;
What is the value of date in the dataset TEMP?
a) 02032000
b) 14643, the number of days from jan 1st , 1960
c) 1460000, the number of days from jan 1st , 1960
d) 02/03/2000
Answer: b
Question: 66
The following code is submitted
data temp;
x=14643;
y=put(x,mmddyy10.);
run;
What would be the attributes of variable Y in the dataset TEMP?
a.) Length of Y is $10.
a) Length of Y is 10
b) Length of Y is 8
c) None
Answer: a
Question: 67
The following code is submitted
data temp;
length y $5;
x=4;
if x=4 then y='four';
else if x=7 then y='seven';
x=7;
run;
What would be the value of X and Y in the dataset temp?
a) X=4 and Y= seven
b) X=7 and Y= seven
c) X=7 and Y= four
d) X=4 and Y= four
Answer: c
Question: 68
Flat file structure is as below
1----5----10
dan 23 45
bob 44 50
sue 30 80
mam 40 50
The following code is submitted.
data temp;
iven ?
a) proc print data=temp label;
label salary='given';
run;
b) proc print data=temp label;
label salary 'given';
run;
c) proc print data=temp;
label salary 'given';
run;
d) proc print data=temp;
label salary='given';
run;
Answer: a
Question: 73
the dataset XYZ is as below
JOBCODE
Chem3
data xyz;
set temp;
if jobcode='CHEM3' then description='senior chemist';
else description='unknown';
run;
What is the value of DESCRIPTION variable in the TEMP dataset?
a) senior chemist
b) unknown
c) senior
d) blank characters
Answer: b
Tip: here we need to use UPCASE (jobcode) in if statement as the character compa
rison is case sensitive.
Question: 74
The TEMP dataset has the values of variables as below
X Y Z
150 less than 200 and gt 100 300
Which of the below code creates the dataset TEMP with above values in the variab
les X, Y, and Z.
a) data temp;
x=150;
if 100 le x le 200 then do;
y='less than 200 and gt 100';
z=300;
end;
else do;
y='other values';
z=400;
end;
run;
b) data temp;
x=150;
if 100 le x le 200 then do;
y='less than 200 and gt 100';
z=300;
else do;
y='other values';
z=400;
end;
run;
c) data temp;
x=150;
Answer: b
Question: 79
Which of the following code creates the permanent dataset MYDATA from temporary
dataset MYDATA?
Libname out sas-library ;
a) data MYDATA;
set MYDATA;
run;
a) data MYDATA;
set out.MYDATA;
run;
b) data out.MYDATA;
set MYDATA;
run;
c) none
Answer: c
Question: 80
See the code below
filename rawdata1 u3x2888.reddy.lib(reddy) ;
libname rawdata2 u3x2888.reddy.saslib
data temp;
infile missing code;
input x y;
run;
What should be inserted in place of missing code?
a) rawdata2
b) rawdata1
c) file
d) none
Answer: b
Question: 81
What is the procedure to print the data portion of the dataset?
a) PROC MEANS
b) PROC SQL
c) PROC PRINT
d) PROC CONTENTS
Answer: c
Question: 82
What is the procedure to see the descriptor portion of the dataset?
a) PROC MEANS
b) PROC SQL
c) PROC PRINT
d) PROC CONTENTS
Answer: d
Question: 83
The variable JOBCODE has length $5 in the dataset TEMP. The same variable presen
t in the dataset TEMP1 and has length $7.
data temp2;
set temp temp1;
run;
What would be the length of the variable JOBCODE in the dataset TEMP2?
a) 5
b) 7
c) We can t see the length as data set won t be created due to errors.
d) None
Answer: a
Tip: whenever we are concatenating the datasets which are having the same variab
le names but having the difference in the attributes like Label, length etc. wil
l be taken from the first dataset that has occurred in the SET statement. Here i
t is TEMP dataset.
Question: 84
One question on using same variable in the ID and BY statement of PROC PRINT.
What will be the value of variable b in the log when following datastep is submi
tted?
Today s date is 31DEC2004;
Data _NULL_;
a=month(today());
b=put(a,date9.);
put b;
run;
a) 13JAN1960;
b) syntax error
c) 31DEC2004
d) 12
Answer:a
Question: 85
Data a has 12 observations and one variable Date as following.
Date_________________________________________________
01/01/2004
02/01/2004
03/02/2004
04/01/2004
05/01/2004
06/01/2004
07/01/2004
08/01/2004
09/01/2004
10/01/2004
11/01/2004
12/01/2004
How many observations will be there dataset b if the following datastep is submi
tted?
Data b;
Set a;
Temp = qtr(input(Date,mmddyy10.));
If Temp LE 3;
RUN;
A) 3
B) 5
C) 9
D) 6
Answer: D
Question: 86
What will be the length of variable LEN when the following code is submitted?
Data temp;
A = I am Bond, James Bond ;
LEN=SCAN(A,3);
Run;
a) 4
b) 20
c) 8
d) 200
Answer: d
Question: 87
What will be the value of variable LEN when the following code is submitted?
Date temp;
A= I was Bond, A real Bond ;
LEN=SUBSTR(A,6,4);
Run;
a) 4
b) 23
c) 1
d) 200
Answer: b
Note: Whenever a variable is created by assigning the value returned by the SCAN
function, its length is always $200 (If it is not set explicitly using length st
atement).
Similarly when a variable is created by assigning the value returned by the SUBS
TR
function, Its length is same as the source string no matter how many character d
id you cut
from the original string. TRANWRD and COMPBL are the other two functions which
return the value of length 200.
Question: 88
How many observations will be there in output dataset temp?
data temp;
x=4;
if x=5 then do;
y=2;
output;
end;
run;
a) 1
b) 2
c) 0
d) 3
Answer: c
Question: 89
Which variables will be present in dataset FINAL;
data FINAL;
set TRY1(KEEP= NUM1 NUM2 NUM3 NUM4)
TRY2(KEEP= NUM5 NUM6 NUM7 NUM8);
DROP NUM2 NUM4 NUM7;
KEEP NUM1 NUM3;
RUN;
A) NUM1 NUM3 NUM5 NUM6 NUM8.
B) NUM1 NUM3;
C) Syntax Error.
D) Warning in the log.
Answer:b
Question: 90
A dataset
SEX_______CITYCODE__________JOB
M NY WER
F NY WER
M WD RES
M WD RES
M SD ED
M WF ED
What will be the correct code to get a cross frequency table as following?
The FREQ Procedure
Table of SEX by CITYCODE
SEX CITYCODE
Frequency
Percent
Row Pct
Col Pct NY SD WD WF
Total
F
1
0
1
16.67
0.00
0
2
16.67
0.00
33.33
50.00
50.00
M
0.00
0.00
50.00
50.00
1
1
1
1
4
16.67
16.67
16.67
25.00
25.00
25.00
50.00
100.00 50.00
0.00
0.00
16.67
66.67
25.00
100.00
Total 2 1 2 1 6
33.33 16.67 33.33 16.67 100.00
a.) PROC FREQ DATA=A;
TABLES SEX*CITYCODE;
RUN;
b.) PROC FREQ DATA=A;
TABLES SEX CITYCODE;
RUN;
PROC FREQ DATA=A;
TABLES SEX, CITYCODE;
RUN;
c.) PROC FREQ DATA=A;
VAR SEX CITYCODE;
RUN;
Answer: a
Li