Thursday, October 4, 2012

Sas Interview Questions 7


What does the following statement do?
libname osiris spss 'c:\myfiles\sasdata\data';
a.         defines a library called Spss using the OSIRIS engine
b.         defines a library called Osiris using the SPSS engine
c.          defines two libraries called Osiris and Spss using the default engine
d.         defines the default library using the OSIRIS and SPSS engines

What does the following OPTIONS statement do?
options pagesize=15 nodate;
a.         suppresses the date and limits the page size of the log
b.         suppresses the date and limits the vertical page size for text output
c.          suppresses the date and limits the vertical page size for text and HTML output
d.         suppresses the date and limits the horizontal page size for text output
As you write and edit SAS programs, it’s a good idea to
a.         begin DATA and PROC steps in column one.
b.         indent statements within a step.
c.          begin RUN statements in column one.
d.         all of the above.
What usually happens when a syntax error is detected?
a.         SAS continues processing the step.
b.         SAS continues to process the step, and the SAS log displays messages about the error.
c.          SAS stops processing the step in which the error occurred, and the SAS log displays messages about the error.
d.         SAS stops processing the step in which the error occurred, and the Output window displays messages about the error.
A syntax error occurs when
a.         some data values are not appropriate for the SAS statements that are specified in a program.
b.         the form of the elements in a SAS statement is correct, but the elements are not valid for that usage.
c.          program statements do not conform to the rules of the SAS language.
d.         none of the above.
How can you tell whether you have specified an invalid option in a SAS program?
a.         A log message indicates an error in a statement that seems to be valid.
b.         A log message indicates that an option is not valid or not recognized.
c.          The message "PROC running" or "DATA step running" appears at the top of the active window.
d.         You can't tell until you view the output from the program.
Which of the following programs contain a syntax error?
a.                proc sort data=sasuser.mysales;
b.                   by region;
c.                run;
d.                dat sasuser.mysales;
e.                   set mydata.sales99;
f.                  run;
g.                proc print data=sasuser.mysales label;
h.                  label region='Sales Region';
i.                  run;
j.           none of the above.
What does the following log indicate about your program?
Image from book
proc print data=sasuser.cargo99
  var origin dest cargorev;
    22
    76
ERROR 22-322: Syntax error, expecting one of the
following:
              ;, (, DATA, DOUBLE, HEADING, LABEL,
              N, NOOBS, OBS, ROUND, ROWS, SPLIT, STYLE,
              UNIFORM, WIDTH.
ERROR 76-322: Syntax error, statement will be ignored.
11         run;
Image from book


a.         SAS identifies a syntax error at the position of the VAR statement.
b.         SAS is reading VAR as an option in the PROC PRINT statement.
c.          SAS has stopped processing the program because of errors.
d.         all of the above
Which PROC PRINT step below creates the following output?
Date
On
Changed
Flight
04MAR99
232
18
219
05MAR99
160
4
219
06MAR99
163
14
219
07MAR99
241
9
219
08MAR99
183
11
219
09MAR99
211
18
219
10MAR99
167
7
219
a.                roc print data=flights.laguardia noobs;
b.                   var on changed flight;
c.                   where on>=160;
d.                run;
e.                proc print data=flights.laguardia;
f.                     var date on changed flight;
g.                   where changed>3;
h.                run;
i.                  proc print data=flights.laguardia label;
j.                     id date;
k.                   var boarded transferred flight;
l.                     label boarded='On' transferred='Changed';
m.                where flight='219';
n.                run;
o.                proc print flights.laguardia noobs;
p.                    id date;
q.                    var date on changed flight;
r.                     where flight='219';
s.                 run;
Which of the following PROC PRINT steps is correct if labels are not stored with the data set?
a.                proc print data=allsales.totals label;
b.                   label region8='Region 8 Yearly Totals';
c.                run;
d.                proc print data=allsales.totals;   label region8='Region 8 Yearly Totals';
e.                run;
f.                  proc print data allsales.totals label noobs;
g.                run;
h.                proc print allsales.totals label;
i.                  run;
Which of the following statements selects from a data set only those observations for which the value of the variable Style is RANCH, SPLIT, or TWOSTORY?
a.         where style='RANCH' or 'SPLIT' or 'TWOSTORY';
b.         where style in 'RANCH' or 'SPLIT' or 'TWOSTORY';
c.          where style in (RANCH, SPLIT, TWOSTORY);
d.         where style in ('RANCH','SPLIT','TWOSTORY');
If you want to sort your data and create a temporary data set named Calc to store the sorted data, which of the following steps should you submit?
a.                proc sort data=work.calc out=finance.dividend;
b.                run;
c.                proc sort dividend out=calc;
d.                   by account;
e.                run;
f.                  proc sort data=finance.dividend out=work.calc;
g.                  by account;
h.                run;
i.                   proc sort from finance.dividend to calc;
j.                     by account;
k.                run;
Which options are used to create the following PROC PRINT output?
Image from book
                           13:27 Monday, March 22, 1999
                                                      
  Patient    Arterial    Heart    Cardiac    Urinary  
                                                      
    203         88        95        66         110    
                                                       
     54         83        183       95           0    
                                                      
    664         72        111       332         12    
                                                      
    210         74        97        369          0    
                                                      
    101         80        130       291          0    
Image from book


a.         the DATE system option and the LABEL option in PROC PRINT
b.         the DATE and NONUMBER system options and the DOUBLE and NOOBS options in PROC PRINT
c.          the DATE and NONUMBER system options and the DOUBLE option in PROC PRINT
d.         the DATE and NONUMBER system options and the NOOBS option in PROC PRINT
Which of the following statements can you use in a PROC PRINT step to create this output?
Month
Instructors
AerClass
WalkJogRun
Swim
01
1
37
91
83
02
2
41
102
27
03
1
52
98
19
04
1
61
118
22
05
3
49
88
29

8
240
497
180
a.                var month instructors;
b.                sum instructors aerclass walkjogrun swim;
c.                var month;
d.                sum instructors aerclass walkjogrun swim;
e.                var month instructors aerclass;
f.                  sum instructors aerclass walkjogrun swim;
g.         all of the above
What happens if you submit the following program?
proc sort data=clinic.diabetes;
run;
proc print data=clinic.diabetes;
  var age height weight pulse;
  where sex='F';
run;
a.         The PROC PRINT step runs successfully, printing observations in their sorted order.
b.         The PROC SORT step permanently sorts the input data set.
c.          The PROC SORT step generates errors and stops processing, but the PROC PRINT step runs successfully, printing observations in their original (unsorted) order.
d.         The PROC SORT step runs successfully, but the PROC PRINT step generates errors and stops processing.
If you submit the following program, which output does it create?
proc sort data=finance.loans out=work.loans;
  by months amount;
run;
proc print data=work.loans noobs;
  var months;
  sum amount payment;
  where months<360 b="b">
run;
a.          
Months
Amount
Payment
12
$3,500
$308.52
24
$8,700
$403.47
36
$10,000
$325.02
48
$5,000
$128.02

$27,200
$1,165.03
b.          
Months
Amount
Payment
12
$3,500
$308.52
24
$8,700
$403.47
36
$10,000
$325.02
48
$5,000
$128.02

27,200
1,165.03
c.           
Months
Amount
Payment
12
$3,500
$308.52
48
$5,000
$128.02
24
$8,700
$403.47
36
$10,000
$325.02

$27,200
$1,165.03
d.          
Months
Amount
Payment
12
$3,500
$308.52
24
$8,700
$403.47
36
$10,000
$325.02
48
$5,000
$128.02


$1,165.03
e.        
Choose the statement below that selects rows in which
§                    the amount is less than or equal to $5000
§                    the account is 101–1092, or the rate equals 0.095.
a.                where amount <= 5000 and
b.                      account='101-1092' or rate = 0.095;
c.                where (amount le 5000 and account='101-1092')
d.                       or rate = 0.095;
e.                where amount <= 5000 and
f.                        (account='101-1092' or rate eq 0.095);
g.                where amount <= 5000 or account='101-1092'
h.                      and rate = 0.095;
What does PROC PRINT display by default?
a.         PROC PRINT does not create a default report; you must specify the rows and columns to be displayed.
b.         PROC PRINT displays all observations and variables in the data set. If you want an additional column for observation numbers, you can request it.
c.          PROC PRINT displays columns in the following order: a column for observation numbers, all character variables, and all numeric variables.
d.         PROC PRINT displays all observations and variables in the data set, a column for observation numbers on the far left, and variables in the order in which they occur in the data set.
Which SAS statement associates the fileref Crime with the raw data file C:\States\Data\Crime?
a.         filename crime 'c:\states\data\crime';
b.         filename crime c:\states\data\crime;
c.          fileref crime 'c:\states\data\crime';
d.         filename 'c:\states\data\crime' crime;
Filerefs remain in effect until
a.         you change them.
b.         you cancel them.
c.          you end your SAS session.
d.         all of the above
Which statement identifies the name of a raw data file to be read with the fileref Products and specifies that the DATA step read only records 1–15?
a.         infile products obs 15;
b.         infile products obs=15;
c.          input products obs=15;
d.         input products 1-15;
Which of the following programs correctly writes the observations from the data set below to a raw data file?
SAS Data Set Work.Patients
ID
Sex
Age
Height
Weight
Pulse
2304
F
16
61
102
100
1128
M
43
71
218
76
4425
F
48
66
162
80
1387
F
57
64
142
70
9012
F
39
63
157
68
6312
M
52
72
240
77
5438
F
42
62
168
83
3788
M
38
73
234
71
9125
F
56
64
159
70
3438
M
15
66
140
67
a.                data _null_;
b.                     set work.patients;
c.                    infile 'c:\clinic\patients\referrals.dat';
d.                    input id 1-4 sex 6 age 8-9 height 11-12
e.                         weight 14-16 pulse 18-20;  
f.                  run;
g.          
h.                data referrals.dat;
i.                       set work.patients;
j.                       input id 1-4 sex 6 age 8-9 height 11-12
k.                         weight 14-16 pulse 18-20;  
l.                  run;
m.        
n.                data _null_;
o.                     set work.patients;
p.                    file c:\clinic\patients\referrals.dat;
q.                     put id 1-4 sex 6 age 8-9 height 11-12
r.                          weight 14-16 pulse 18-20;    
s.                 run;
t.            
u.                data _null_;
v.                     set work.patients;
w.                   file 'c:\clinic\patients\referrals.dat';
x.                     put id 1-4 sex 6 age 8-9 height 11-12
y.                         weight 14-16 pulse 18-20;  
z.                run;
Which raw data file can be read using column input?
a.          
Image from book
b.          
Image from book
c.           
Image from book
d.         all of the above
Which program creates the output shown below?
Image from book
Obs
ID
LastName
FirstName
City
1
3427
Chen
Steve
Raleigh
2
1436
Davis
Lee
Atlanta
3
2812
King
Vicky
Memphis
4
1653
Sanchez
Jack
Atlanta
a.                data work.salesrep;
b.                      infile empdata;
c.                     input ID $ 1-4 LastName $ 6-12
d.                           FirstName $ 14-18 City $ 20-29;
e.                  run;
f.                  proc print data=work.salesrep;
g.                run;
h.                data work.salesrep;
i.                        infile empdata;
j.                        input ID $ 1-4 Name $ 6-12
k.                           FirstName $ 14-18 City $ 20-29;
l.                  run;
m.              proc print data=work.salesrep;
n.                run;
o.                data work.salesrep;
p.                      infile empdata;
q.                      input ID $ 1-4 name1 $ 6-12
r.                           name2 $ 14-18 City $ 20-29;
s.                 run;
t.                  proc print data=work.salesrep;
u.                run;
v.          all of the above
Which statement correctly reads the fields in the following order: StockNumber, Price, Item, Finish, Style?
Field Name  Start Column  End Column   Data Type
StockNumber      1             3       character
Finish           5             9       character
Style           11            18       character
Item            20            24       character
Price           27            32       numeric
Image from book
a.                input StockNumber $ 1-3 Finish $ 5-9 Style $ 11-18
b.                       Item $ 20-24 Price 27-32;
c.                 input StockNumber $ 1-3 Price 27-32
d.                      Item $ 20-24 Finish $ 5-9 Style $ 11-18;
e.                input $ StockNumber 1-3 Price 27-32
f.                        $ Item  20-24 $ Finish 5-9 $ Style 11-18;
g.                input StockNumber $ 1-3 Price $ 27-32
h.                      Item $ 20-24 Finish $ 5-9 Style $ 11-18;
Which statement correctly re-defines the values of the variable Income as 100 percent higher?
a.         income=income*1.00;
b.         income=income+(income*2.00);
c.          income=income*2;
d.         income= *2;
Which program correctly reads instream data?
a.                data finance.newloan;
b.                   input datalines;
c.                   if country='JAPAN';
d.                   MonthAvg=amount/12;
e.                1998 US     CARS   194324.12
f.                  1998 US     TRUCKS 142290.30
g.                1998 CANADA CARS    10483.44
h.                1998 CANADA TRUCKS  93543.64
i.                  1998 MEXICO CARS    22500.57
j.                  1998 MEXICO TRUCKS  10098.88
k.                1998 JAPAN  CARS    15066.43
l.                  1998 JAPAN  TRUCKS  40700.34
m.              ;
n.                data finance.newloan;
o.                    input Year 1-4 Country $ 6-11
p.                         Vehicle $ 13-18 Amount 20-28;
q.                    if country='JAPAN';
r.                     MonthAvg=amount/12;
s.                     datalines;
t.                  run;
u.                data finance.newloan;
v.                    input Year 1-4 Country 6-11
w.                       Vehicle 13-18 Amount 20-28;
x.                    if country='JAPAN';
y.                    MonthAvg=amount/12;
z.                    datalines;
aa.            1998 US     CARS   194324.12
bb.            1998 US     TRUCKS 142290.30
cc.             1998 CANADA CARS    10483.44
dd.            1998 CANADA TRUCKS  93543.64
ee.            1998 MEXICO CARS    22500.57
ff.                1998 MEXICO TRUCKS  10098.88
gg.            1998 JAPAN  CARS    15066.43
hh.            1998 JAPAN  TRUCKS  40700.34
ii.                ;
jj.                 data finance.newloan;
kk.                 input Year 1-4 Country $ 6-11
ll.                         Vehicle $ 13-18 Amount 20-28;
mm.           if country='JAPAN';
nn.                MonthAvg=amount/12;
oo.                datalines;
pp.            1998 US     CARS   194324.12
qq.            1998 US     TRUCKS 142290.30
rr.               1998 CANADA CARS    10483.44
ss.              1998 CANADA TRUCKS  93543.64
tt.                1998 MEXICO CARS    22500.57
uu.            1998 MEXICO TRUCKS  10098.88
vv.             1998 JAPAN  CARS    15066.43
ww.         1998 JAPAN  TRUCKS  40700.34
xx.            ;
Which SAS statement subsets the raw data shown below so that only the observations in which Sex (in the second field) has a value of F are processed?
Image from book
a.         if sex=f;
b.         if sex=F;
c.          if sex='F';
d.         a or b
Which of the following is not created during the compilation phase?
a.         the data set descriptor
b.         the first observation
c.          the program data vector
d.         the _N_ and _ERROR_ automatic variables
During the compilation phase, SAS scans each statement in the DATA step, looking for syntax errors. Which of the following is not considered a syntax error?
a.         incorrect values and formats
b.         invalid options or variable names
c.          missing or invalid punctuation
d.         missing or misspelled keywords
Unless otherwise directed, the DATA step executes
a.         once for each compilation phase.
b.         once for each DATA step statement.
c.          once for each record in the input file.
d.         once for each variable in the input file.
At the beginning of the execution phase, the value of _N_ is 1, the value of _ERROR_ is 0, and the values of the remaining variables are set to
a.         0
b.         1
c.          undefined
d.         missing
Suppose you run a program that causes three DATA step errors. What is the value of the automatic variable _ERROR_ when the observation that contains the third error is processed?
a.         0
b.         1
c.          2
d.         3
Which of the following actions occurs at the end of the DATA step?
a.         The automatic variables _N_ and _ERROR_ are incremented by one.
b.         The DATA step stops execution.
c.          The descriptor portion of the data set is written.
d.         The values of variables created in programming statements are re-set to missing in the program data vector.
Look carefully at the DATA step shown below. Based on the INPUT statement, in what order will the variables be stored in the new data set?
data perm.update;
  infile invent;
  input IDnum $ 15-19 Item $ 1-13 Instock 21-22
         BackOrd 24-25;
  Total=instock+backord;
run;
a.         IDnum Item InStock BackOrd Total
b.         Item IDnum InStock BackOrd Total
c.          Total IDnum Item InStock BackOrd
d.         Total Item IDnum InStock BackOrd
If SAS cannot interpret syntax errors, then
a.         data set variables will contain missing values.
b.         the DATA step does not compile.
c.          the DATA step still compiles, but it does not execute.
d.         the DATA step still compiles and executes.
What is wrong with this program?
data perm.update;
   infile invent
   input Item $ 1-13 IDnum $ 15-19 Instock 21-22
         BackOrd 24-25;
   total=instock+backord;
run;
a.         missing semicolon on second line
b.         missing semicolon on third line
c.          incorrect order of variables
d.         incorrect variable type
Look carefully at this section of a SAS session log. Based on the note, what was the most likely problem with the DATA step?
Image from book
NOTE: Invalid data for IDnum in line 7 15-19.
RULE: ----+----1----+----2----+----3----+----4
7       Bird Feeder LG088 3 20
Item=Bird Feeder IDnum=. InStock=3 BackOrd=20
Total=23 _ERROR_=1 _N_=1
Image from book


a.         A keyword was misspelled in the DATA step.
b.         A semicolon was missing from the INFILE statement.
c.          A variable was misspelled in the INPUT statement.
d.         A dollar sign was missing in the INPUT statement.
If you don't specify the LIBRARY= option, your formats are stored in Work.Formats, and they exist
1.          only for the current procedure.
2.          only for the current DATA step.
3.          only for the current SAS session.
4.          permanently.
290. 
Which of the following statements will store your formats in a permanent catalog?
1.            libname library 'c:\sas\formats\lib';proc format lib=library ...;
2.            libname library 'c:\sas\formats\lib';format lib=library ...;
3.            library='c:\sas\formats\lib';proc format library ...;
4.            library='c:\sas\formats\lib';proc library ...;
When creating a format with the VALUE statement, the new format's name
§                    cannot end with a number
§                    cannot end with a period
§                    cannot be the name of a SAS format, and
1.          cannot be the name of a data set variable.
2.          must be at least two characters long.
3.          must be at least eight characters long.
4.          must begin with a dollar sign ($) if used with a character variable.
Which of the following FORMAT procedures is written correctly?
1.            proc format lib=library value colorfmt; 1='Red' 2='Green' 3='Blue' run;
2.            proc format lib=library; value colorfmt 1='Red' 2='Green' 3='Blue'; run;
3.            proc format lib=library; value colorfmt; 1='Red' 2='Green' 3='Blue' run;
4.            proc format lib=library; value colorfmt 1='Red'; 2='Green'; 3='Blue'; run;
Which of these is false? Ranges in the VALUE statement can specify
1.          a single value, such as 24 or 'S'.
2.          a range of numeric values, such as 0–1500.
3.          a range of character values, such as 'A'–'M'.
4.          a list of numeric and character values separated by commas, such as 90,'B',180,'D',270.
How many characters can be used in a label?
1.          40
2.          96
3.          200
4.          256
Which keyword can be used to label missing values as well as any values that are not specified in a range?
1.          LOW
2.          MISS
3.          MISSING
4.          OTHER
You can place the FORMAT statement in either a DATA step or a PROC step. What happens when you place the FORMAT statement in a DATA step?
1.          You temporarily associate the formats with variables.
2.          You permanently associate the formats with variables.
3.          You replace the original data with the format labels.
4.          You make the formats available to other data sets.
The format JOBFMT was created in a FORMAT procedure. Which FORMAT statement will apply it to the variable JobTitle in the program output?
1.          format jobtitle jobfmt;
2.          format jobtitle jobfmt.;
3.          format jobtitle=jobfmt;
4.          format jobtitle='jobfmt';
Which keyword, when added to the PROC FORMAT statement, will display all the formats in your catalog?
1.          CATALOG
2.          LISTFMT
3.          FMTCAT
4.          FMTLIB
If Style has four unique values and you submit the following program, which output do you get? (Assume that all the other variables are numeric.)
proc report data=sasuser.houses nowd;
   column style sqfeet bedrooms price;
   define style / group;
run;
a.           
Style
SqFeet
Bedrooms
Price
CONDO
6755
11
$397,250
RANCH
5005
9
$274,300
SPLIT
4110
8
$233,950
TWOSTORY
5835
12
$335,300
b.           
Style
SqFeet
Bedrooms
Price
CONDO
1400
2
$80,050

1390
3
$79,350

2105
4
$127,150

1860
2
$110,700
RANCH
1250
2
$64,000

1500
3
$86,650

1535
3
$89,100

720
1
$34,550
SPLIT
1190
1
$65,850

1615
4
$94,450

1305
3
$73,650
TWOSTORY
1810
4
$107,250

1040
2
$55,850

1240
2
$69,250

1745
4
$102,950
c.            
Style
SqFeet
Bedrooms
Price
15
21705
40
$1,240,800
d.           
Style
SqFeet
Bedrooms
Price
RANCH
1250
2
$64,000
SPLIT
1190
1
$65,850
CONDO
1400
2
$80,050
TWOSTORY
1810
4
$107,250
RANCH
1500
3
$86,650
SPLIT
1615
4
$94,450
SPLIT
1305
3
$73,650
CONDO
1390
3
$79,350
TWOSTORY
1040
2
$55,850
CONDO
2105
4
$127,150
RANCH
1535
3
$89,100
TWOSTORY
1240
2
$69,250
RANCH
720
1
$34,550
TWOSTORY
1745
4
$102,950
CONDO
1860
2
$110,700
e.        
When you define an order variable,
a.         the detail rows are ordered according to their formatted values.
b.         you can't create summary reports.
c.          PROC REPORT displays only the first occurrence of each order variable value in a set of rows that have the same value for all order variables.
d.         all of the above
Which attributes or options are reflected in this PROC REPORT output?
style         SqFeet           Price
------------------------------------
                                   
 RANCH             720       $34,550
TWOSTORY          1040       $55,850
 SPLIT            1190       $65,850
TWOSTORY          1240       $69,250
 RANCH            1250       $64,000
 SPLIT            1305       $73,650
 CONDO            1390       $79,350
 CONDO            1400       $80,050
 RANCH            1500       $86,650
 RANCH            1535       $89,100
 SPLIT            1615       $94,450
TWOSTORY          1745      $102,950
TWOSTORY          1810      $107,250
 CONDO            1860      $110,700
 CONDO            2105      $127,150
a.         SKIPLINE and FORMAT=
b.         CENTER, HEADLINE, HEADSKIP, and either WIDTH=, SPACING=, or FORMAT=
c.          SPACING= only
d.         CENTER, FORMAT=, and HEADLINE
To create a summary report that shows the average number of bedrooms and the maximum number of baths for each style of house, which DEFINE statements do you use in your PROC REPORT step?
a.                define style / center 'Style of/House';
b.                define bedrooms / mean 'Average/Bedrooms';
c.                define baths / max 'Maximum/Baths';
d.                define style / group;
e.                define bedrooms / mean 'Average/Bedrooms';
f.                  define baths / max 'Maximum/Baths';
g.                define style / order;
h.                define bedrooms / mean 'Average/Bedrooms';
i.                  define baths / max 'Maximum/Baths';
j.                  define style / group;
k.                define bedrooms / 'Average/Bedrooms';
l.                  define baths / 'Maximum/Baths'

No comments: