Thursday, October 4, 2012

Sas Interview Questions 9


How is the variable Amount labeled and formatted in the PROC PRINT output?
data credit;
   infile creddata;
   input Account $ 1-5 Name $ 7-25 Type $ 27
         Transact $ 29-35 Amount 37-50;
   label amount='Amount of Loan';
   format amount dollar12.2;
  
run;

proc print data=credit label;
    label amount='Total Amount Loaned';
   format amount comma10.;
run;
a.         label Amount of Loan, format DOLLAR12.2
b.         label Total Amount Loaned, format COMMA10.
c.          label Amount, default format
d.         The PROC PRINT step does not execute because two labels and two formats are assigned to the same variable.
Consider the IF-THEN statement shown below. When the statement is executed, which expression is evaluated first?
if finlexam>=95
   and (research='A' or
       (project='A' and present='A'))
   then Grade='A+';
a.         finlexam>=95
b.         research='A'
c.          project='A' and present='A'
d.         research='A' or
(project='A' and present='A')
Consider the small raw data file and program shown below. What is the value of Count after the fourth record is read?
Image from book
a.         missing
b.         0
c.          30
d.         70
Now consider the revised program below. What is the value of Count after the third observation is read?
Image from book
a.         missing
b.         0
c.          100
d.         130
For the observation shown below, what is the result of the IF-THEN statement?
Status
Type
Count
Action
Control
ok
3
12
E
Go
if status='OK' and type=3
   then Count+1;
if status='S' or action='E'
   then Control='Stop';
a.         Count = 12 Control = Go
b.         Count = 13 Control = Stop
c.          Count = 12 Control = Stop
d.         Count = 13 Control = Go
Which of the following can determine the length of a new variable?
a.         the length of the variable's first value
b.         the assignment statement
c.          the LENGTH statement
d.         all of the above
Which set of statements is the most efficient equivalent to the code shown below?
if code='1' then Type='Fixed';
if code='2' then Type='Variable';
if code^='1' and code^='2' then Type='Unknown';
a.                if code='1' then Type='Fixed';
b.                else if code='2' then Type='Variable';
c.                else Type='Unknown';
d.                if code='1' then Type='Fixed';
e.                if code='2' then Type='Variable';
f.                  else Type='Unknown';
g.                if code='1' then type='Fixed';
h.                else code='2' and type='Variable';
i.                  else type='Unknown';
j.                  if code='1' and type='Fixed';
k.                then code='2' and type='Variable';
l.                  else type='Unknown';
What is the length of the variable Type, as created in the DATA step below?
data finance.newloan;
   set finance.records;
   TotLoan+payment;
   if code='1' then Type='Fixed';
   else Type='Variable';
   length type $ 10;
run;
a.         5
b.         8
c.          10
d.         It depends on the first value of Type.
Which program contains an error?
a.                data clinic.stress(drop=timemin timesec);
b.                    infile tests;
c.                    input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
d.                          RecHR 35-37 TimeMin 39-40 TimeSec 42-43
e.                          Tolerance $ 45;
f.                      TotalTime=(timemin*60)+timesec;
g.                    SumSec+totaltime;
h.                run;
i.                  proc print data=clinic.stress;
j.                      label totaltime='Total Duration of Test';
k.                    format timemin 5.2;
l.                      drop sumsec;
m.              run;
n.                proc print data=clinic.stress(keep=totaltime timemin);
o.                    label totaltime='Total Duration of Test';
p.                    format timemin 5.2;
q.          
r.                 run; data clinic.stress;
s.                     infile tests;
t.                      input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
u.                          RecHR 35-37 TimeMin 39-40 TimeSec 42-43
v.                          Tolerance $ 45;
w.                  TotalTime=(timemin*60)+timesec;
x.                    keep id totaltime tolerance;
y.                run;
If you submit the following program, which variables appear in the new data set?
data work.cardiac(drop=age group);
   set clinic.fitness(keep=age weight group);
   if group=2 and age>40;
run;
a.         none
b.         Weight
c.          Age, Group
d.         Age, Weight, Group
Which of the following programs correctly reads the data set Orders and creates the data set FastOrdr?
a.                data catalog.fastordr(drop=ordrtime);
b.                    set july.orders(keep=product units price);
c.                    if ordrtime<4 span="span">
d.                    Total=units*price;
e.                run;
f.                  data catalog.orders(drop=ordrtime);
g.                    set july.fastordr(keep=product units price);
h.                   if ordrtime<4 span="span">
i.                      Total=units*price;
j.                  run;
k.                data catalog.fastordr(drop=ordrtime);
l.                      set july.orders(keep=product units price
m.                                  ordrtime);
n.                    if ordrtime<4 span="span">
o.                    Total=units*price;
p.                run;
q.         none of the above
Which of the following statements is false about BY-group processing?
When you use the BY statement with the SET statement,
a.         the data sets that are listed in the SET statement must be indexed or sorted by the values of the BY variable(s).
b.         the DATA step automatically creates two variables, FIRST. and LAST., for each variable in the BY statement.
c.          FIRST. and LAST. identify the first and last observation in each BY group, in that order.
d.         FIRST. and LAST. are stored in the data set.
There are 500 observations in the data set Company.USA. What is the result of submitting the following program?
data work.getobs5(drop=obsnum);
   obsnum=5;
   set company.usa(keep=manager payroll) point=obsnum;
   stop;
run;
a.         an error
b.         an empty data set
c.          a continuous loop
d.         a data set that contains one observation
There is no end-of-file condition when you use direct access to read data, so how can your program prevent a continuous loop?
a.         Do not use a POINT= variable.
b.         Check for an invalid value of the POINT= variable.
c.          Do not use an END= variable.
d.         Include an OUTPUT statement.
Assuming that the data set Company.USA has five or more observations, what is the result of submitting the following program?
data work.getobs5(drop=obsnum);
   obsnum=5;
   set company.usa(keep=manager payroll) point=obsnum;
   output;
   stop;
run;
a.         an error
b.         an empty data set
c.          a continuous loop
d.         a data set that contains one observation
Which of the following statements is true regarding direct access of data sets?
a.         You cannot specify END= with POINT=.
b.         You cannot specify OUTPUT with POINT=.
c.          You cannot specify STOP with END=.
d.         You cannot specify FIRST. with LAST.
What is the result of submitting the following program?
data work.addtoend;
   set clinic.stress2 end=last;
   if last;
run;
a.         an error
b.         an empty data set
c.          a continuous loop
d.         a data set that contains one observation
At the start of DATA step processing, during the compilation phase, variables are created in the program data vector (PDV), and observations are set to
a.         blank
b.         missing
c.          0
d.         there are no observations.
The DATA step executes
a.         continuously if you use the POINT= option and the STOP statement.
b.         once for each variable in the output data set.
c.          once for each observation in the input data set.
d.         until it encounters an OUTPUT statement.
Which program will combine Brothers.One and Brothers.Two to produce Brothers.Three?
Image from book
a.                data brothers.three;
b.                    set brothers.one;
c.                    set brothers.two;
d.                run;
e.                data brothers.three;
f.                      set brothers.one brothers.two;
g.                run;
h.                data brothers.three;
i.                      set brothers.one brothers.two;
j.                      by varx;
k.                run;
l.                  data brothers.three;
m.                  merge brothers.one brothers.two;
n.                   by varx;
o.                run;
Which program will combine Actors.Props1 and Actors.Props2 to produce Actors.Props3?
Image from book
a.                data actors.props3;
b.                    set actors.props1;
c.                    set actors.props2;
d.                run;
e.                data actors.props3;
f.                      set actors.props1 actors.props2;
g.                run;
h.                data actors.props3;
i.                      set actors.props1 actors.props2;
j.                      by actor;
k.                run;
l.                  data actors.props3;
m.                  merge actors.props1 actors.props2;
n.                   by actor;
o.                run;
If you submit the following program, which new data set is created?
Image from book
data work.jobsatis;
   set work.dataone work.datatwo;
run;
a.           
Career
Supervis
Finance
Variety
Feedback
Autonomy
72
26
9
.
.
.
63
76
7
.
.
.
96
31
7
.
.
.
96
98
6
.
.
.
84
94
6
.
.
.
.
.
.
10
11
70
.
.
.
85
22
93
.
.
.
83
63
73
.
.
.
82
75
97
.
.
.
36
77
97
b.           
Career
Supervis
Finance
Variety
Feedback
Autonomy
72
26
9
10
11
70
63
76
7
85
22
93
96
31
7
83
63
73
96
98
6
82
75
97
84
94
6
36
77
97
c.            
Career
Supervis
Finance
72
26
9
63
76
7
96
31
7
96
98
6
84
94
6
10
11
70
85
22
93
83
63
73
82
75
97
36
77
97
d.         none of the above
If you concatenate the data sets below in the order shown, what is the value of Sale in observation 2 of the new data set?
Image from book
a.         missing
b.         $30,000
c.          $40,000
d.         you cannot concatenate these data sets
What happens if you merge the following data sets by variable SSN?
Image from book
a.         The values of Age in the 1st data set overwrite the values of Age in the 2nd data set.
b.         The values of Age in the 2nd data set overwrite the values of Age in the 1st data set.
c.          The DATA step fails because the two data sets contain same-named variables that have different values.
d.         The values of Age in the 2nd data set are set to missing.

No comments: