Thursday, October 4, 2012

Sas Interview Questions 6



201. The following program is submitted.
data test;
input name $ age;
cards;
John +35
;run;

 Which values are stored in the output data set?

A. name age
John 35
B. name age
John (missing value)
C. name age
(missing value) (missing value)
D. The DATA step fails execution due to data errors.
Ans: a
202.The following observation is stored in a SAS data set named EMPLOYEES:
LNAME FNAME JOBCODE
----------------------------------------------------------------------
Whitley Sam na1

If the DATA step below is executed, what will be the value of the variable JOBDESC in the output SAS data
set when this observation is processed:

data navigate;
set employees;
if jobcode = 'NA1' then jobdesc = 'Navigator';
run;
A. navigator
B. Navigator
C. NAVIGATOR
D. a missing value
ans: d
203.The following SAS program is submitted:

proc format;
value score 1 - 50 = 'Fail'
51 - 100 = 'Pass';
run;

Which one of the following PRINT procedure steps correctly applies the format?
A. proc print data = sasuser.class;
    var test;
    format test score;
    run;
B. proc print data = sasuser.class;
    var test;
    format test score.;
    run;
C. proc print data = sasuser.class format = score;
    var test;
    run;
D. proc print data = sasuser.class format = score.;
    var test;
    run;
Ans: b
204 Given the following DATA step:
data loop;
x = 0;
do index = 1 to 5 by 2;
x = index ;
end;
run;

Upon completion of execution, what are the values of the variables X and INDEX in the SAS data set named
LOOP?
A. x = 3, index = 3
B. x = 3, index = 4
C. x = 5, index = 5
D. x = 5, index = 6
E. x = 5, index = 7
Ans: E
205 Given that the data set named ONE contains 10 observations and the data set named TWO contains 10
observations, how many observations will be contained in the data set named COMBINE that is created in
the following DATA step?

data combine;
set one two;
run;
A. 10
B. 20
C. 0, the DATA step will fail due to syntax errors
D. 10 to 20, depending on how many observations match

ans: b
 206. A format statement should be specified before the CARDS statement when we read internal raw data.
a. True
b. False

Ans: true
207. An external file with a maximum record length of 225 is read into SAS in a DATA step. Select all statements that reads the data correctly.
a. INFILE ‘C:\mydata.dat’ LRECL=2000;
b. INFILE ‘C:\mydata.dat’ LRECL=225;
c. INFILE ‘C:\mydata.dat’ ;

208. Select the False statement about List Input method of reading data
a. Reads data separated by several spaces.
b. Does not skip over unwanted values in the input data.
c. Reads a date.

Ans: c
209. Column Input style can read a character data value with space embedding
a. True
b. False

Ans: a
210. A standard numeric data in SAS can contain a ‘-‘ (negative) sign and ‘E’ for scientific notations
a. True
b. False

Ans: a
211. A non standard data (Numbers with comma, dates like ’03-OCT-2005’ ) can be read with the following INPUT styles (select all correct answers)
a. Formatted Input
b. Modified List Input
c. Using Informats in INPUT statement

212. Given the line of raw data:
112233 SCODES Z M N
And the data statement:
INPUT @'SCODES' statuscodes :$10.;

When executed in a DATA step correctly, what value the variable ‘Statuscodes’ gets?

a. Z
b. Z M N
c. . (Missing)

ans: a

213. The following statement is submitted:
Data Test;
INPUT accnum $ / fname $ lname $ ;
cards;
12223242 Johny Smith
Peter Smith Thomas Joseph
;run;

The output dataset will show which of the following?
a. accnum fname lname
12223242 Johny Smith

b. accnum fname lname
12223242 Peter Smith

c. None of the above
ans: b
214. The following statement is submitted:
Data Test;
INPUT accnum $ #2 fname $ lname $ ;
cards;
12223242 Johny Smith
Peter Smith Thomas Joseph
;run;

The output dataset will show which of the following?
a. accnum fname lname
12223242 Johny Smith

b. accnum fname lname
12223242 Peter Smith
c. None of the above

ans: b
215. The following INPUT statements are submitted:
Data Test;
INPUT accnum $ fname $ lname $ @@ ;
cards;
122232 Johny Smith 132343 Peter Smith 142434 Thomas Joseph;
run;

Which of the following statement is correct?
a. Output record set will have only one record
b. Output record set will have 3 records
c. Data step incomplete due to incorrect syntax

ans: b
 216. Datafile ‘c:\mydata.dat’ contains account number, first name and last name of account holders with following structure.
122232 Johny Smith
142434 Thomas
152535 Dan Paul

Which statement below reads the data correctly into SAS.
a. Data Test;
INFILE 'c:\mydata.dat' MISSOVER;
INPUT accnum $ 1-6 fname $ 8-14 lname $ 16-20;
run;

b. Data Test;
INFILE 'c:\mydata.dat' TRUNCOVER;
INPUT accnum $ 1-6 fname $ 8-14 lname $ 16-20;
run;

c. Data Test;
INFILE 'c:\mydata.dat' ;
INPUT accnum $ fname $ lname $;
run;

ans: c with missover option
217. The following statement is submitted
Data Test;
INFILE 'c:\mydata.dat’;
INPUT client_id $ 1-3 @;
IF client_id 'JCP' then delete;
INPUT accnum $ 4-8 fname $ 9-14 lname $ 16-20;
run;

How many columns will be there in dataset ‘Test’ ?
a. None
b. 3
c. 4

ans: may be a

218. An external data file has account open date in the following format .

01-13-95
01-14-96
01-15-97

Which of the following is a correct INPUT statement in DATA step to read this data.
a. INPUT Account_no mmddyy8. ;
b. INPUT Account_no mmddyy6. ;
c. INPUT Account_no ddmmyy8. ;

ans: a
219. The following statements are submitted
Data Test;
today = '20dec2005'd;
format today mmddyy10.;
run;

Which of the following statement is true ?
a. ‘Today’ variable displays like ‘12/20/2005’
b. Data step not executed due to wrong format ‘mmddyy’.
c. Today is displayed as ‘20DEC2005’

ans: a
220. Following statements are submitted:
proc export data = Account_perf outfile = 'd:\text1.csv';
run;

proc export data = Account_perf outfile = 'd:\text2.csv'
DBMS =DLM REPLACE;
DELIMITER =',';
run;

Select all false statements:
a. There are two files , text1.csv and text2.csv , created in d:\
b. Both text1 and text2 files have the same data values delimited by a comma
c. Text1 data file will have a space-delimited data as a standard SAS output.
d. Only text2.csv is created with values delimited by a comma.

Ans: may be d
Note: the programs in the example e expects no errors due to improper use of ;, ‘’, ) etc.
221. File C:\mydata.dat contains 100 complete records and the following program is submitted.
options obs=10;
Data Test;
INFILE 'c:\mydata.dat' firstobs=3;
INPUT accnum $ fname $ lname $;
run;

Which of the following statement is correct?
a. Test data set will have 98 rows
b. Test dataset will have first 10 observations
c. Test dataset will have 10 observations read starting from third data line in mydata.dat
d. Test dataset will have 8 observations read starting from third data line in mydata.dat

Ans: may be d
222. The following program is submitted to read a delimited file
Data Test;
INFILE 'c:\mydata.dat' DLM='$' DSD ;
INPUT accnum $ fname $ lname $;
run;

What ‘DSD’ keyword does here? (Select all correct answers)
a. It does not treat ‘$’ character as part of the data value and treat it as delimiter.
b. It recognize two consecutive ‘$’ characters as a missing value for the variable read
c. If data value is specified in quotes with embedded ‘$’ character DSD option treats it as part of the data.

Ans: b
223. A PROC DATATSETS is used as follows(assumption: all libraries are and datasets are existing):
proc datasets library=mylib details;
copy out=rloc;
select scoredata;
delete tension ;
run;
Which statement below explains the operations above most correctly?

a. It lists all SAS data files with file size and date modified in ‘mylib’ library and makes a copy of ‘scoredata’ file in ‘rloc’ library and deletes ‘tension’ dataset..
b. It lists all SAS data files with file size and date modified in ‘mylib’ library and deletes ‘tension’ file from ‘rloc’ library.
c. It lists all SAS data files with file size and date modified in ‘mylib’ library and makes a copy of ‘scoredata’ file in ‘rloc’ library and also copies the ‘scoredata’ file in ‘rloc’ library.
d. It lists all sas data files with file size and date modified in ‘mylib’ library and makes a copy of ‘scoredata’ file in ‘rloc’ library.

224. The following program is submitted. Which is a false statement about the output of this program?
proc contents data=scoredata;
run;

a. Prints # of observations in ‘scoredata’
b. Prints a snapshot of the data into the screen.
c. Prints the date ‘scoredata’ was created
d. Lists all labels associated with variables in ‘scoredata’


225. The following line of code is used in a SAS data step .
Data xx;
Set yy;
attrib status_codes length=$4 label ='Status Codes' format =$upcase8.;
run;

If yy has a variable names status_codes and the user wants the attributes to be changed in xx . Will this statement change the length, label and format in xx dataset?
a. YES
b. NO
c. No Sufficient Information


226. The below three program blocks are submitted
A) Data target_data ;
Set base_data((keep = var1 var2 var3 );
Run;

B) Data target_data ;
Set base_data;
keep = var1 var2 var3 ;
Run;

C) Data target_data (keep = var1 var2 var3 );
Set base_data;
Run;

If the user needs only var1, var2 and var3 to work with, which step is most efficient?
a. A
b. B
c. C
d. A&B
e. None

ans: a

227. The following program is submitted (Assumption is os_dollars is an existing dataset with client groups (client_group) and dollar outstanding (os) fields. ) .
Data test;
SET os_dollars END=FIN ;
BY client_group;
t_os +os;
IF LAST.clinet_group THEN DO ;
g_os +t_os ;
t_os=0;END;run;

What this program does?
a. Computes the gross outstanding across the groups and store it in g_os variable, last row.
b. Computes the oustandings for client groups and retain them in t_os variable
c. None of the above.


228. The following program was submitted to SAS
data temp;
length my_number $ 4;
input my_number;
cards;
1234
0009
;run;

data new(drop=x);
set temp(rename=(my_number=x));
my_number=input(x,best4.);run;

proc print data=new;run;
What’s the output would be?
A) Obs my_number
       1     1234
       2     9
B) Obs my_number
       1    1234
       2    0009
C) Obs my_number
        .       .

Ans: A
229. The following program is submitted:
x='20jan94'd;
y=qtr(x);
put y=;

What value would be printed to the SAS log?
a. 1
b. 2
c. 3
d. None

ans: a
230. The following program submitted:
data xx;
date1=122591;
date2=put(date1,z6.);run;

What’s the data type of date1 and date 2 ?
a. Date1 Character, Date 2 Numeric
b. Date1 numeric, Date 2 character
c. Syntax error, not executed

Ans: b
 231. The following statement forms a part of SAS dataset (no syntax errors)

Data xx;
Set yy;
array weight wt1-wt50;
do i=1 to 50;
if weight{i}=999 then weight{i}=’missing’;
end;
run;

Select all correct statements below:
a. Creates a variable weight and assigns w1-wt50 (wt1, wt2, wt3 etc)
b. Variables named wt1-wt50 exist in the’ yy’ data set.
c. If any of the fields in wt1-wt50 have a value of ‘999’ then it will be reset with a ‘missing’ .
d. Evaluated all 50 fields and the entire table looking for value ‘999’ in any of the fields

 ans: b,c
232. The following program is submitted:
proc report data =xx nowindows headline headskip ;
Title 'Summary across groups’;
column s_g N (os co), MEAN ;
define s_g /group;
run;

What’s the objective of using MEAN?
a. Compute mean (Average) of variables OS and CO
b. Compute mean and N(count) of s_g and MEAN of OS and CO
c. Compute mean and N(count) of s_g and MEAN of OS and CO by s_g groups.

How many observations and variables does the data set below contain?
Name
Sex
Age
Picker
M
32
Fletcher

28
Romano
F
.
Choi
M
42
a.         3 observations, 4 variables
b.         3 observations, 3 variables
c.          4 observations, 3 variables
d.         can't tell because some values are missing
How many program steps are executed when the program below is processed?
data user.tables;
   infile jobs;
   input date name $ job $;
run;
proc sort data=user.tables;
   by name;
run;
proc print data=user.tables;
run;
a.         three
b.         four
c.          five
d.         six
What type of variable is the variable AcctNum in the data set below?
AcctNum
Balance
3456_1
M
2451_2

Romano
F
Choi
M
a.         numeric
b.         character
c.          can be either character or numeric
d.         can't tell from the data shown
What type of variable is the variable Wear in the data set below?
Brand
Wear
Acme
43
Ajax
34
Atlas
.
A.         numeric
B.         character
C.         can be either character or numeric
D.         can't tell from the data shown
Which of the following variable names is valid?
a.         4BirthDate
b.         $Cost
c.          _Items_
d.         Tax-Rate
Which of the following files is a permanent SAS file?
a.         Sashelp.PrdSale
b.         Sasuser.MySales
c.          Profits.Quarter1
d.         all of the above
In a DATA step, how can you reference a temporary SAS data set named Forecast?
a.         Forecast
b.         Work.Forecast
c.          Sales.Forecast (after assigning the libref Sales)
d.         only a and b above
What is the default length for the numeric variable Balance?
Name
Balance
Adams
105.73
Geller
107.89
Martinez
97.45
Noble
182.50
a.         5
b.         6
c.          7
d.         8
How many statements does the following SAS program contain?
proc print data=new.prodsale
                label double;
  var state day price1 price2; where state='NC';
  label state='Name of State';
run;
a.         three
b.         four
c.          five
d.         six
What is a SAS data library?
a.         a collection of SAS files, such as SAS data sets and catalogs
b.         in some operating environments, a physical collection of SAS files
c.          in some operating environments, a logically related collection of SAS files
d.         all of the above
243. 
If you submit the following program, how does the output look?
options pagesize=55 nonumber;
proc tabulate data=clinic.admit;
   class actlevel;
   var age height weight;
   table actlevel,(age height weight)*mean;
run;
options linesize=80;
  proc means data=clinic.heart min max maxdec=1;
  var arterial heart cardiac urinary;
  class survive sex;
run;
a.         The PROC MEANS output has a print line width of 80 characters, but the PROC TABULATE output has no print line width.
b.         The PROC TABULATE output has no page numbers, but the PROC MEANS output has page numbers.
c.          Each page of output from both PROC steps is 55 lines long and has no page numbers, and the PROC MEANS output has a print line width of 80 characters.
d.         The date does not appear on output from either PROC step.
In order for the date values 05May1955 and 04Mar2046 to be read correctly, what value must the YEARCUTOFF= option have?
a.         a value between 1947 and 1954, inclusive
b.         1955 or higher
c.          1946 or higher
d.         any value
When you specify an engine for a library, you are always specifying
a.         the file format for files that are stored in the library.
b.         the version of SAS that you are using.
c.          access to other software vendors' files.
d.         instructions for creating temporary SAS files.
Which statement prints a summary of all the files stored in the library named Area51?
a.         proc contents data=area51._all_ nods;
b.         proc contents data=area51 _all_ nods;
c.          proc contents data=area51 _all_ noobs;
d.         proc contents data=area51 _all_.nods;
The following PROC PRINT output was created immediately after PROC TABULATE output. Which SAS system options were specified when the report was created?
                                     1   
          10:03 Friday, March 17, 2000    
                                         
                      Act                
Obs  ID Height Weight Level   Fee        
                                         
1   2458  72     168   HIGH   85.20      
2   2462  66     152   HIGH  124.80       
3   2501  61     123   LOW   149.75      
4   2523  63     137   MOD   149.75      
5   2539  71     158   LOW   124.80      
6   2544  76     193   HIGH  124.80      
7   2552  67     151   MOD   149.75      
8   2555  70     173   MOD   149.75       
9   2563  73     154   LOW   124.80      
a.         OBS=, DATE, and NONUMBER
b.         PAGENO=1 and DATE
c.          NUMBER and DATE only
d.         none of the above
Which of the following programs correctly references a SAS data set named SalesAnalysis that is stored in a permanent SAS library?
a.                data saleslibrary.salesanalysis;
b.                   set mydata.quarter1sales;
c.                   if sales>100000;
d.                run;
e.                data mysales.totals;
f.                     set sales_99.salesanalysis;
g.                   if totalsales>50000;
h.                run;
i.                   proc print data=salesanalysis.quarter1;
j.                    var sales salesrep month;
k.                run;
 
l.                  proc freq data=1999data.salesanalysis;
m.                 tables quarter*sales;
n.                run;
Which time span is used to interpret two-digit year values if the YEARCUTOFF= option is set to 1950?
a.         1950-2049
b.         1950-2050
c.          1949-2050
d.         1950-2000
Assuming you are using SAS code and not special SAS windows, which one of the following statements is false?
a.         LIBNAME statements can be stored with a SAS program to reference the SAS library automatically when you submit the program.
b.         When you delete a libref, SAS no longer has access to the files in the library. However, the contents of the library still exist on your operating system.
c.          Librefs can last from one SAS session to another.
d.         You can access files that were created with other vendors' software by submitting a LIBNAME statement.

No comments: