Вы находитесь на странице: 1из 24

Sample SAS certification Questions

(Questions asked in Base SAS certification exam)


Question: 1
The following SAS program is submitted:
proc means data = sasuser.houses std mean max;
var sqfeet run;
Which one of the following is needed to display the standard deviation with only
two decimal places?
A. Add the option MAXDEC = 2 to the MEANS procedure statement.
B. Add the statement MAXDEC = 7.2; in the MEANS procedure step.
C. Add the statement FORMAT STD 7.2; in the MEANS procedure step.
D. Add the option FORMAT = 7.2 option to the MEANS procedure statement.
Answer: A
Question: 2
Which one of the following is true when SAS encounters a data error in a DATA st
ep?
A. The DATA step stops executing at the point of the error, and no SAS data set
is created.
B. A note is written to the SAS log explaining the error, and the DATA step cont
inues to execute.
C. A note appears in the SAS log that the incorrect data record was saved to a s
eparate SAS file for further examination.
D. The DATA step stops executing at the point of the error, and the resulting DA
TA set contains observations up to that point.
Answer: B
Question: 3
The following SAS program is submitted:
data work.total;
set work.salary(keep = department wagerate);
by department;
if first.department then payroll = 0;
payroll + wagerate;
if last.department;
run;
The SAS data set WORK.SALARY, currently ordered by DEPARTMENT, contains 100
observations for each of 5 departments.
Which one of the following represents how many observations the WORK.TOTAL data
set contains?
A. 5
B. 20
C. 100
D. 500
Answer: A
Question: 4
The following SAS program is submitted:
data work.retail;
cost = 20000 ;
total = .10*cost;
run;
Which one of the following is the value of the variable TOTAL in the output data
set?
A. 2000
B. 2000
C. (missing numeric value)
D.
(missing character value)
Answer: A
Question: 5
The following SAS program is submitted:
libname sasdata SAS-data-library ;
data test;

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;

B. define style / group width = 9;


C. define style / across width = 9;
D. define style / display width = 9;
Answer: B
Question: 12
The following SAS program is submitted:
data work.staff;
JobCategory = FA ;
JobLevel = 1 ;
Jobcategory = Jobcategory || JobLevel;
run;
Which one of the following is the value of the variable JOBCATEGORY in the outpu
t data set?
A. FA
B. FA1
C. FA 1
D. (missing character value)
Answer: A
Question: 13
The SAS data set named WORK.TEST is listed below:
Capacity airplanetype staff
150 Large 10
Which one of the following SAS programs created this data set?
A. data work.test
capacity = 150;
1100 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 ; airplanetype = Small ;
staff = 5;
end;
run;
D. data work.test;D.data work.test;
capacity = 150;
if 100 le capacity le 200 then;
airplanetype = Small ; airplanetype = Small ;
staff = 5;
else;
airplanetype = Large ; airplanetype = Large ;
staff = 10;
run;
Answer: B
Question: 14
The following SAS program is submitted:

libname rawdata1 location of SAS data library ;


filename rawdata2 location of raw data file ;
data work.testdata;
infile <insert item here>;
input sales1 sales2;
run;
Which one of the following is needed to complete the program correctly?
A. rawdata1
B. rawdata2
C. rawdata1
D. rawdata2
Answer: B
Question: 15
The following SAS SORT procedure step generates an output data set:
proc sort data = sasuser.houses out = report;
by style;
run;
In which library is the output data set stored?
A. WORK
B. REPORT
C. HOUSES
D. SASUSER
Answer: A
Question: 16
A raw data record is shown below:
07Jan2002
Which one of the following in formats would read this value and store it as a SA
S date value?
A. date9.
B. dmonyy9.
C. ddMMMyy9.
D. ddmmmyyyy9.
Answer: A
Question: 17
The following SAS DATA step is submitted:
libname temp SAS-data-library ;
data temp.report;
set sasuser.houses;
newvar = price * 1.04;
run;
Which one of the following statements is true regarding the program above?
A. The program is reading from a temporary data set and writing to a temporary d
ata set.
B. The program is reading from a temporary data set and writing to a permanent d
ata set.
C. The program is reading from a permanent data set and writing to a temporary d
ata set.
D. The program is reading from a permanent data set and writing to a permanent d
ata set.
Answer: D
Question: 18
A raw data record is listed below:
----|----10----|----20----|----30
Printing 750
The following SAS program is submitted:
data bonus;
infile file-specification ;
input dept $ 1-11 number 13-15;
<insert code here>
run;

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

if date = 01012000 d then event = January 1st;


run;
Which one of the following is the value of the EVENT variable?
Question: 22
The SAS data set SASUSER.HOUSES contains a variable PRICE which has been assigne
d a permanent label of Asking Price . Which SAS program temporarily replaces the la
bel Asking Price with the label Sale Price in the output?
A - proc print data = sasuser.houses; label price = Sale Price ; run;
B - proc print data = sasuser.houses label; label price Sale Price ; run;
C - proc print data = sasuser.houses label; label price = Sale Price ; run;
D - proc print data = sasuser.houses; price = Sale Price ; run;
Answer: C
Question: 23
The following GAS program is submitted:
data work.empsalary;
set work.people (in = inemp)
work.money (in = insal);
if insal and inemp;
run;
The SAG data set WORKPEOPLE has 5 observations, and the data set WORKMONEY has 7
observations. How many observations will the data set WORK.EMPSALARY contain?
A - 0
B - 5
C - 7
D - 12
Answer: A
Question: 24
The following SAS program is submitted:
data work.accounting;
set work.dept1 work.dept2;
jobcode = FA1 ;
length jobcode $ 8;
run;
A character variable named JOBCODE is contained in both the WORK.DEPT1 and
WORK.DEPT2 SAS data sets. The variable JOBCODE has a length of 5 in the WORK.DEP
T1
data set and a length of 7 in the WORK.DEPT2 data set. What is the length of the
variable
JOBCODE in the output data set?
A - 3
B - 5
C - 7
D - 8
Answer: B
Question: 25
Given the SAS data set SASDATA.TWO:
SASDATA.TWO
X Y
-- -5 2
5 4
3 6
The following SAS program is submitted:
data sasuser.one one sasdata.three;
set sasdata two;
if x = 5 then output sasuser.one;
else output sasdata three;
run;
What is the result?
A - The data set SASUSER.ONE has 0 observations, the data set ONE has 0 observat

ions, and the data set SASDATA.THREE has 0 observations.


B - The data set SASUSER.ONE has 2 observations, the data set ONE has 0 observat
ions, and the data set SASDATA.THREE has 1 observation.
C - The data set SASUSER.ONE has 2 observations, the data set ONE has 3 observat
ions, and the data set SASDATA.THREE has 1 observation.
D - No data sets are output. The DATA step fails execution due to errors.
Answer: B
Question: 26
The following SAS program is submitted:
footnote 1 Sales Report for Last Month ;
footnote2 Selected Products Only ;
footnote3 All Regions ;
footnote4 All Figures in Thousands of Dollars ;
proc print data = sasuser.shoes;
footnote2 All Products ;
run;
Which footnote(s) is/are displayed in the report?
A - All Products
B - Sales Report for Last Month All Products
C - All Products All Regions All Figures in Thousands of Dollars
D - Sales Report for Last Month All Products All Regions All Figures in Thousand
s of Dollars
Answer: B
Question: 27
Given the raw data record DEPT:
----|----10---|----20---|----30
Printing 750
The following SAS program is submitted:
data bonus;
infile dept ;
inputdept$ 1-11 number 13- 15;
<insert statement here>
run;
Which SAS statement completes the program and results in a value of Printing750
r the DEPARTMENT variable?
A - department = dept II number;
B - department = left(dept) II number;
C - department = trim(dept) number;
D - department = trim(dept) put(number,3.);
Answer: D
Question: 28
The following SAS program is submitted:
data one;
addressl = 214 London Way ;
run;
data one;
set one;
address = tranwrd(address1, Way , Drive ); run;
What are the length and value of the variable ADDRESS?
A - Length is 14; value is 214 London Dri .
B - Length is 14; value is 214 London Way .
C - Length is 16; value is 214 London Drive .
D - Length is 200; value is 214 London Drive .
Answer: D
Question: 29
The following SAS program is submitted:
data work.sets;
do until (prod gt 6);
prod + 1;
end;

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

options obs = 500;


Data TEMP;
Set test(firstobs = 75);
Run;
What will be the number of observations in temp dataset?
a.) 424
b.) 425
c.) 500
d.) 75
e.) 426
Answer: e
Question: 39
PROC SORT data = temp;
BY Descending JOBCODE SALARY;
RUN;
Temp DATASET
JOBCODE SALARY AGE
X1 100 20
X2 100 10
X2 200 20
A1 100 10
A2 200 10
A2 200 40
What will be the output??
Answer:
Temp DATASET
JOBCODE SALARY AGE
X2 100 10
X2 200 20
X1 100 20
A2 200 10
A2 200 40
A1 100 10
Question: 40
PROC SORT DATA = TEMP;
By Jobcode DESCENDING Salary;
RUN;
What will be the first observation? (Apply this on dataset created in last quest
ion)
Answer:
Temp DATASET
JOBCODE SALARY AGE
A1 100 10
A2 200 10
A2 200 40
X1 100 20
X2 200 20
X2 100 10
8.) DATA TEMP;
MERGE X1 X2;
BY ID;
RUN;
How many observations and variables will be there in temp dataset?
X1 DATASET X2 DATASET
ID NAME ID CLASS
1 ANKUR 1 A
2 VIJAY 1 B
2 B
2 A
Answer: 3 variables and 4 observations

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

d.) syntax error


Answer: b
Question: 55
data temp;
set test1(in = a) /* 2 observations*/
test2(in=b); /* 5 observations*/
if a and b;
run;
How many observations will be there in temp dataset?
a.) 2
b.) 5
c.) 7
d.) 0
Answer: 0 (Good question, repeated many times. Note a and
Question: 56
data temp;
set test; /* 100 observations 20 for each ID*/
by ID;
if first,ID then name = RAJU ;
else if ID = RAM then name = RAMU ;
if last.ID;
run;
How many observations will be present in temp dataset?
a.) 5
b.) 20
c.) 100
d.) 0
Answer: a
Question: 57
Question on PROC PRINT with BY statement;
libname temp abc.sds.as ;
data temp.X1.
set sasuser.X2;
run;
Which is the correct statement??
a.) In datastep input is read from temporary location and
emporary location.
b.) In datastep input is read from permanent location and
emporary location.
c.) In datastep input is read from temporary location and
ermanent location.
d.) In datastep input is read from permanent location and
ermanent location.
Answer: d
Question: 58
What is the output of DATE9. format?
a.)11/31/2000
b.) 31/11/2000
c.) 31NOV2000
e.) 01NOVEMBER2000
Answer: c
Question: 59
Why PROC FSLIST is used?
a.) to write to an external file
b.) to read from an external file
c.) to sort by date
d.) not a valid statement
Answer: b
Question: 60
1----5----10----15----20 (filename = abc )

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;

infile file specification ;


input x $ 1-3;
if x='sue' then input age 5-6;
else input height 8-9;
run;
What would be the value of variable AGE in the dataset TEMP when variable X has
the value Sue ?
a) 30
b) 44
c) 40
d) 55
Answer: c
Question: 69
Flat file structure is as below (Very good question)
1----5----10
vital reddy 45
vijay 30
sarma 40
The following code is submitted.
data temp;
infile file specification ;
input x $ age;
if age<=40;
run;
How many observations will be there in the TEMP dataset?
a) 3
b) 2
c) zero observations
d) syntax error
Answer: a
Question: 70
The following code is submitted.
data temp;
salary='20000';
bonus=0.1*salary;
run;
What would be the value of BONUS variable in the dataset TEMP?
a) 2000
b) 2000
c) .(period)
d) blank
Answer: b
Question: 71
The following code is submitted.
data temp;
salary=.;
if salary=. then salary=100;
bonus=10;
salary=.;
total=sum(salary,bonus);
run;
What would be the value of TOTAL variable in the dataset TEMP?
a) 100
b) 110
c) 10
d) .(period)
Answer: c
Question: 72
The descriptor portion of the dataset TEMP has the label of variable SALARY as Ac
tual salary . Which of the below code changes the label of the variable SALARY to g

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;

if 100 le x le 200 then


y='less than 200 and gt 100';
z=300;
else do;
y='other values';
z=400;
end;
run;
d) None
Answer: a
Question: 75
Flat file structure is as below
1----5----10
23 44
The following code is submitted.
data temp;
infile file specification ;
input @1 weight 2. @4 height 2.;
run;
What is the value of HEIGHT variable in the TEMP dataset?
a) . (period)
b) Blank
c) 44
d) 23
Question: 76
Following code is submitted.
data temp:
do i=1 to 3;
do j=1 to 4;
salary=salary+300;
end;
end;
run;
how many observations will present in the dataset TEMP?
a) 1
b) 3
c) 2
d) 0
Answer: a
Question: 77
The dataset XYZ has 5000 observations.
options obs=500;
proc print data=xyz(firstobs=100 )
run;
options obs=max;
proc means data=xyz(firstobs=500)
run;
How many observations processed in each procedure?
a) 401 in the proc print and 4501 in the proc means
b) 5000 in the proc print and 500 in the proc means
c) 500 in the proc print and 5000 in the proc means
d) 4501 in the proc print and 401 in the proc means
Answer: a
Question: 78
Which of the following code calculates the mean of variables var1, var2, var3, a
nd var4.
a) MEAN(var1-var4)
b) MEAN(of var1-var4)
c) MEAN(var1 var2 var3 var4)
d) MEAN(var1)

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

Вам также может понравиться