100% found this document useful (1 vote)
206 views

SAS Interview Practice Question With Answers

SAS practive questions for Pharma students https://pharmawiki.in/sas-interview-practice-question-a-quintiles-accenture/ https://www.youtube.com/watch?v=KQWm865kpu0 SAS interview practice video

Uploaded by

RepurnaChitturi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
206 views

SAS Interview Practice Question With Answers

SAS practive questions for Pharma students https://pharmawiki.in/sas-interview-practice-question-a-quintiles-accenture/ https://www.youtube.com/watch?v=KQWm865kpu0 SAS interview practice video

Uploaded by

RepurnaChitturi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 50

SAS Interview Practice

Question and Answers


Pharmawiki.in
The following SAS program is submitted:
data test;
set sasuser.employees;
if 2 le years_service le 10 then amount=1000;
else if years_service gt 10 then amount=2000;
else amount=0;
amount_per_year=years_serice/amount; run;
 
Which one of the following values does the variable AMOUNT_PER_YEAR contain if an
employee has been with the company for one year?
 
A. 0
B. 1000
C. 2000

D. . (missing numeric value) Answer: D


The contents of the raw data file NAMENUM are listed below:
----|----10---|----20---|----30
Joe xx
The following SAS program is submitted:
data test; infile'namenum'; input name $ number; run;
Which one of the following is the value of the NUMBER variable?
A. xx
B. Joe
C. . (missing numeric value)

D. The value can not be determined as the program fails to execute due to errors.
Answer: C
Which one of the following statements is true regarding the SAS
automatic
_ERROR_ variable?

A. The _ERROR_ variable contains the values 'ON' or 'OFF'.


B. The _ERROR_ variable contains the values 'TRUE' or 'FALSE'.
C. The _ERROR_ variable is automatically stored in the resulting
SAS data set.
D. The _ERROR_ variable can be used in expressions or calculations
in the DATA step.

Answer: D
The following SAS program is submitted:
data work.totalsales (keep=monthsales{12});
set work.monthlysales (keep=year product sales); srray monthsales {12};
doi=1 to 12; monthsales{i}=sales; end;
run;
The data set named WORK.MONTHLYSALES has one observation per month for each of five
years for a total of 60 observations.
Which one of the following is the result of the above program?

A. The program fails execution due to data errors.


B. The program fails execution due to syntax errors.
C. The program executes with warnings and creates the WORK.TOTALSALES data set.
D. The program executes without errors or warnings and creates the WORK.TOTALSALES
data set.
E. Answer: B
The following SAS program is submitted:
data work.january;
set work.allmonths (keep=product month num_sold cost); if month='jan'then
output work.january; sales=cost*num_sold;
keep=product sales; run;
Which variables does the WORK.JANUARY data set contain?

A. PRODUCT and SALES only


B. PRODUCT, MONTH, NUM_SOLD and COST only
C. PRODUCT, SALES, MONTH, NUM_SOLD and COST only
D. An incomplete output data set is created due to syntax errors.

Answer: D
A SAS program is submitted and the following SAS log is produced: 2 data gt100;
3 set ia.airplanes
4 if mpg gt 100 then output; 22 202
ERROR: File WORK.IF.DATA does not exist. ERROR: File WORK.MPG.DATA does not exist. ERROR: File
WORK.GT.DATA does not exist.
ERROR: File WORK.THEN.DATA does not exist. ERROR: File WORK.OUTPUT.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: a name,
a quoted string, (,;.END,KEY,KEYS,NOBS,OPEN,POINT,_DATA_,_LAST_,
_NULL_.
ERROR 202-322: The option or parameter is not recognized and will be ignored. 5 run;
The IA libref was previously assigned in this SAS session. Which one of the following corrects the errors in the
LOG?

A. Delete the word THEN on the IF statement.


B. Add a semicolon at the end of the SET statement.
C. Place quotes around the value on the IF statement.
D. Add an END statement to conclude the IF statement.

Answer: B
The contents of the raw data file EMPLOYEE are listed below:
----|----10---|----20---|----30
Ruth 39 11
Jose 32 22
Sue 30 33
John 40 44
The following SAS program is submitted: data test;
in file' employee';
input employee_ name $ 1-4;

if employee_ name = 'Ruthh' then input idnum 10-11; else input age 7-8;
run
Which one of the following values does the variable IDNUM contain when the name of the employee is
"Ruth"?

A. 11
B. 22
C. 32
D. . (missing numeric value) Answer: B
The following SAS program is submitted:
footnote1 'Sales Report for last Mounth'; footnote2 'Selected Products Only'; footnote3 'All
Regions';
footnote4 'All Figure in Thousands of Dollars'; proc print data = sasuser.shoes;
footnote2 'All products'; run;
Which one of the following contains the footnote text that is 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 Thousands of Dollars
Answer: B
Which one of the following SAS system options
prevents the page number from appearing on a
report?

A.NONUM
B.NOPAGE
C.NONUMBER
D.NOPAGENUM Answer: C
The following SAS program is submitted:
proc means data = sasuser.houses std mean max; varsqfeet;
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
Unless specified, which variables and data values are used to calculate statistics
in the MEANS procedure?

A. non-missing numeric variable values only


B. missing numeric variable values and non-missing numeric variable values
only
C. non-missing character variables and non-missing numeric variable values
only
D. missing character variables, non-missing character variables, missing
numeric variable values, and non-missing numeric variable values

Answer: A
A realtor has two customers. One customer wants to view a list of homes selling for less than
$60,000. The other customer wants to view a list of homes selling for greater than $100,000.
Assuming the PRICE variable is numeric, which one of the following PRINT procedure steps will
select all desired observations?

A. proc print data = sasuser.houses; where price lt 60000;


where price gt 100000; run;
B. proc print data = sasuser.houses; where price lt 60000 or price gt 100000; run;
C. proc print data = sasuser.houses; where price lt 60000 and price gt 100000; run;
D. proc print data = sasuser.houses;
where price lt 60000 or where price gt 100000; run;

Answer: B
The value 110700 is stored in a numeric variable.
Which one of the following SAS formats is used to
display the value as $110,700.00 in a report?

A. comma8.2
B. comma11.2
C. dollar8.2
D.dollar11.2

E.Answer D
The SAS data set SASUSER.HOUSES contains a variable PRICE which has been assigned a
permanenlabel of "Asking Price".
Which one of the following SAS programs temporarily replaces the label "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 label = "Sale Price"; run;

Answer: C
The SAS data set BANKS is listed below:
BANKS
name rate FirstCapital0.0718 DirectBank0.0721 VirtualDirect0.0728
The following SAS program is submitted:
data newbank; do year = 1 to 3; set banks; capital + 5000; end;
run;
Which one of the following represents how many observations and variables
will exist in the SAS data set NEWBANK?

A. 0 observations and 0 variables


B. 1 observations and 4 variables
C. 3 observations and 3 variables
D. 9 observations and 2 variables
E. Answer: B
The SAS data set BANKS is listed below:
BANKS
name rate FirstCapital0.0718 DirectBank0.0721 VirtualDirect0.0728
The following SAS program is submitted:
data newbank; do year = 1 to 3; set banks; capital + 5000; end;
run;
Which one of the following represents how many observations and variables will exist in the SAS
data set NEWBANK?

A. 0 observations and 0 variables


B. 1 observations and 4 variables
C. 3 observations and 3 variables
D. 9 observations and 2 variables

Answer: B
The following SAS program is submitted:
data work.clients; calls = 6;
do while (calls le 6); calls + 1;
end; run;
Which one of the following is the value of the variable CALLS in the
output data set?

A. 4
B. 5

C. 6
D. 7
Answer: D
The following SAS program is submitted:
data work.pieces; do while (n lt 6); n + 1;
end; run;
Which one of the following is the value of the variable N in the output data set?

A. 4
B. 5
C. 6
D. 7
Answer: C
The following SAS program is submitted:

data work.sales; do year = 1 to 5;


do month = 1 to 12;
x + 1;
end; end; run;
Which one of the following represents how many observations are written to
the WORK.SALES data set?

A. 0
B. 1
C. 5
D. 60
Answer: B
A raw data record is listed below:
----|----10---|----20---|----30 1999/10/25
The following SAS program is submitted:
data projectduration; infile' file-specification'; input date $ 1 - 10;
<insert statement here> run;
Which one of the following statements completes the program above and
computes the duration of the project in days as of today's date?

A. duration = today( ) - put(date,ddmmyy 10.);


B. duration = today( ) - put(date,yymmdd 10.);
C. duration = today( ) - input(date,ddmmyy 10.);
D. duration = today( ) - input(date,yymmdd 10.);
Answer: D
Which one of the following is true of the RETAIN statement in a SAS
DATA step program?

A. It can be used to assign an initial value to _N_ .


B. It is only valid in conjunction with a SUM function.
C. It has no effect on variables read with the SET, MERGE and
UPDATE statements.
D. It adds the value of an expression to an accumulator variable and
ignores missing values.

Answer: C
A raw data file is listed below:
----|----10---|----20---|----30 1901 2
1905 1
1910 6

1925 .
1941 1
The following SAS program is submitted and references the raw data file above: data coins;
infile'file-specification'; input year quantity;
<insert statement(s) here> run;
Which one of the following completes the program and produces a non-missing value for the
variable TOTQUANTITY in the last observation of the output data set?

A. totquantity + quantity;
B. totquantity = sum(totquantity + quantity);
C. totquantity 0; sum totquantity;
D. retain totquantity 0;
totquantity = totquantity = quantity;
Answer: A
A raw data file is listed below:
----|----10---|----20---|----30
squash 1.10
apples 2.25
juice 1.69
The following SAS program is submitted using the raw data file above: data groceries;
infile'file-specification'; input item $ cost;
<insert statement(s) here>
Which one of the following completes the program and produces a grand total for all COST
values?

A. grandtot = sum cost;


B. grandtot = sum(grandtot,cost);
C. retain grandtot 0;
grandtot = sum(grandtot,cost);
D. grandtot = sum(grandtot,cost); output grandtot;

Answer: C
The following SAS program is submitted: data work.total;
set work.salary(kep = 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
The following SAS program is submitted:
data work.total;
set work.salary(kep = department wagerate); by department;
if first.department then payroll = 0; payroll + wagerate;
if last.department; run;
The SAS data set named WORK.SALARY contains 10 observations for each department,
currently ordered by DEPARTMENT.
Which one of the following is true regarding the program above?

A. The BY statement in the DATA step causes a syntax error.


B. FIRST.DEPARTMENT and LAST.DEPARTMENT are variables in the WORK.TOTAL data
set.
C. The values of the variable PAYROLL represent the total for each department in the
WORK.SALARY data set.
D. The values of the variable PAYROLL represent a total for all values of WAGERATE in the
WORK.SALARY data set.

Answer: C
The following SAS program is submitted:
libnamesasdata 'SAS-data-library'; data test;
set sasdata.chemists (keep = job_code); if job_code = 'chem3'
then description = 'Senior Chemist'; run;
The variable JOB_CODE is a character variable with a length of 6
bytes. Which one of the following is the length of the variable
DESCRIPTION in the output data set?

A. 6 bytes
B. 8 bytes
C. 14 bytes
D. 200 bytes
Answer: C
The following SAS program is submitted:
data work.passengers;
if OrigPassengers = . then OrigPassengers=100; TransPassengers= 100;
OrigPassengers= .; NonPaying= 10;
TotalPassengers= sum (OrigPassengers, TransPassengers); run;
Which one of the following is the value of the TOTALPASSENGERS
variable in the output data set?

A. 100
B. 110
C. 200
missing numeric value)
D. . (
Answer: A
The following SAS program is submitted:
data work.company;
set work.dept1(keep = jobcode) work.dept2(rename = (jcode =
jobcode)); run;
Which one of the following is the result?

A. The variable JCODE is written to the output data set.


B. The variable JOBCODE is written to the output data set.
C. Neither variable JCODE nor JOBCODE is written to the output
data set.
D. The program fails to execute due to errors.

Answer: B
Which one of the following SAS statements renames two variables?
A. set work.dept1
work.dept2(rename = (jcode = jobcode) (sal = salary));
B. set work.dept1
work.dept2(rename = (jcode = jobcode

sal = salary));
C. set work.dept1
work.dept2(rename = jcode = jobcode sal = salary);
D. set work.dept1 work.dept2(rename = (jcode jobcode) (sal salary));

Answer: B
The following SAS DATA step is submitted:
data work.accountting; set work.department; length jobcode$ 12; run;
The WORK.DEPARTMENT SAS data set contains a character variable named
JOBCODE with a length of 5.
Which one of the following is the length of the variable JOBCODE in the output
data set?

A. 5
B. 8
C. 12
D. The length can not be determined as the program fails to execute due to
errors.

Answer: A
The following SAS program is submitted:
data work.accounting;
set work.dept1 work.dept2; 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.DEPT1 data set and a length of 7 in the WORK.DEPT2 data set.
Which one of the following is the length of the variable JOBCODE in the output
data set?

A. 5
B. 7
C. 8
D. 12
Answer: A
In the following SAS program, the input data files are sorted by the NAMES
variable:
libnametemp 'SAS-data-library'; data temp.sales;
merge temp.sales work.receipt;
by names; run;
Which one of the following results occurs when this program is submitted?
A. The program executes successfully and a temporary SAS data set is created.
B. The program executes successfully and a permanent SAS data set is created.
C. The program fails execution because the same SAS data set is referenced for
both read and write operations.
D. The program fails execution because the SAS data sets on the MERGE
statement are in two different libraries.
Answer: B
 
A raw data file is listed below: RANCH,1250,2,1,Sheppard Avenue,"$64,000"
SPLIT,1190,1,1,Rand Street,"$65,850" CONDO,1400,2,1.5,Market Street,"80,050"
TWOSTORY,1810,4,3,Garris Street,"$107,250" RANCH,1500,3,3,Kemble Avenue,"$86,650"
SPLIT,1615,4,3,West Drive,"94,450" SPLIT,1305,3,1.5,Graham Avenue,"$73,650"
The following SAS program is submitted using the raw data file as input: data
work.condo_ranch;

infile'file-specification' dsd; input style $ @;


if style = 'CONDO' or style = 'RANCH';
input sqfeet bedrooms baths street $ price : dollar10.; run;
How many observations will the output data set contain?
A. 0
B. 3
C. 5
D. 7 Answer: B
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 item1 $ 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
The following SAS program is submitted and reads 100 records
from a raw data file:
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 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; Answer: D
A raw data record is listed below:
----|----10---|----20---|----30
son,Travis,
The following output is desired:
relation firstname son Travis
Which one of the following SAS programs reads the data correctly?
A. data family / dlm = ','; infile 'file-specification'; input relation $ firstname $; run;
B. option dlm = ','; data family;
infile 'file-specification'; input relation $ firstname $; run;
C. data family;
infile 'file-specification' option dlm = ','; input relation $ firstname $;
run;
D. data family;
infile 'file-specification';
input relation $ firstname $ / dlm = ','; run;
Answer: C
The following SAS program is submitted:
proc print data = sasuser.houses; run;
<insert OPTIONS statement here> proc means data = sasuser.shoes;
run;
Which one of the following OPTIONS statements resets the page
number to 1 for the second report?
A. option pageno = 1;
B. option pagenum = 1;
C. options reset pageno = 1;
D. options reset pagenum = 1;
B. Answer: A
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 work = '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
Which one of the following is true of the SUM statement in
a SAS DATA step program?
A. It is only valid in conjunction with a SUM function.
B. It is not valid with the SET, MERGE and UPDATE
statements.
C. It adds the value of an expression to an accumulator
variable and ignores missing values.
D. It does not retain the accumulator variable value from
one iteration of the SAS DATA step to the next.
Answer: C
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
Which one of the following SAS DATA steps saves the temporary data set
named MYDATA as a permanent data set?
A. libname sasdata 'SAS-data-library'; data sasdata.mydata;
copy mydata; run;
B. libname sasdata 'SAS-data-library'; data sasdata.mydata;
keep mydata; run;
C. libname sasdata 'SAS-data-library'; data sasdata.mydata;
save mydata; run;
D. libname sasdata 'SAS-data-library'; data sasdata.mydata;
set mydata; run;
Answer: D
The following SAS DATA step is submitted:
data sasdata.atlanta sasdata.boston work.portland work.phoenix;
set company.prdsales;
if region = 'NE' then output bostan; if region = 'SE' then output atlanta;
if region = 'SW' then output phoenix; if region = 'NW' then output portland;
run;
Which one of the following is true regarding the output data sets?
A. No library references are required.
B. The data sets listed on all the IF statements require a library reference.
C. The data sets listed in the last two IF statements require a library reference.
D. The data sets listed in the first two IF statements require a library reference.
A raw data file is listed below:
----|----10---|----20---|----30
John McCloskey 35 71
June Rosesette 10 43
TinekeJones 9 37
The following SAS program is submitted using the raw data file as input: data
work.homework;
infile 'file-specification'; input name $ age height; if age LE 10;
run;
How many observations will the WORK.HOMEWORK data set contain?
A. 0
B. 2
C. 3
D. No data set is created as the program fails to execute due to errors.
Answer: C
The SASDATA.BANKS data set has five observations when the following SAS

program is submitted:
libnamesasdata 'SAS-date-library'; data allobs;
set sasdata.banks; capital=0;
do year = 2000 to 2020 by 5; capital + ((capital+2000) * rate); output;
end;
How many observations will the ALLOBS data set contain?
A. 5
B. 15
C. 20
D. 25 Answer: D
The following SAS program is submitted:
data allobs;
set sasdata.origin (firstobs = 75 obs = 499); run;
The SAS data set SASDATA.ORIGIN contains 1000 observations. How
many observations does the ALLOBS data set contain?
A. 424
B. 425
C. 499
D. 1000
Answer: B
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
The following SAS program is submitted:? libnametemp 'SAS-data-library';
data work.new; set temp.jobs;
format newdate mmddyy10.; qdate= qtr(newdate);
ddate= weekday(newdate); run;
proc print data = work.new; run;
The variable NEWDATE contains the SAS date value for April 15, 2000. What
output is produced if April 15, 2000 falls on a Saturday?
A. Obs newdate qdate ddate 1 APR152000 2 6
B. Obs newdate qdate ddate 1 04/15/2000 2 6
C. Obs newdate qdate ddate 1 APR152000 2 7
D. Obs newdate qdate ddate 1 04/15/2000 2 7
Answer: D
The following SAS program is submitted:
data revenue; set year_1;
var1 = mdy(1,15,1960); run;
Which one of the following values does the variable named VAR1
contain?
A. 14
B. 15
C. 1151960
D. '1/15/1960'
Answer: A
The following SAS DATA step executes on Monday, April 25, 2000: data
newstaff;
set staff; start_date=today();

run;
Which one of the following is the value of the variable START_DATE in the
output data set?
A. a character string with the value '04/25/2000'
B. a character string with the value 'Monday, April 25, 2000'
C. the numeric value 14725, representing the SAS date for April 25, 2000
D. the numeric value 04252000, representing the SAS date for April 25, 2000
Answer: C

You might also like