Friday, March 2, 2012


Which SAS program was used to create the raw data file Teamdat from the SAS data set Work.Scores?
SAS Data Set Work.Scores
Obs
Name
HighScore
Team
1
Joe
87
Blue Beetles, Durham
2
Dani
79
Raleigh Racers, Raleigh
3
Lisa
85
Sand Sharks, Cary
4
Matthew
76
Blue Beetles, Durham
Image from book
a.     data _null_;
b.       set work.scores;
c.        file 'c:\data\teamdat' dlm=',';
d.       put name highscore team; run;
e.      
f.      data _null_;
g.       set work.scores;
h.       file 'c:\data\teamdat' dlm=' ';
i.         put name highscore team;
j.      run;
k.      
l.      data _null_;
m.      set work.scores;
n.       file 'c:\data\teamdat' dsd;
o.       put name highscore team;
p.    run;
q.    data _null_;
r.        set work.scores;
s.        file 'c:\data\teamdat';
t.         put name highscore team;
u.    run;
Which SAS statement reads the raw data values in order and assigns them to the variables shown below?
Variables: FirstName (character), LastName (character), Age (numeric), School (character), Class (numeric)
Image from book
a.     input FirstName $ LastName $ Age School $ Class;
b.    input FirstName LastName Age School Class;
c.     input FirstName $ 1-4 LastName $ 6-12 Age 14-15
d.          School $ 17-19 Class 21;
e.     input FirstName 1-4 LastName 6-12 Age 14-15
f.            School 17-19 Class 21;
Which SAS statement should be used to read the raw data file that is referenced by the fileref Salesrep?
Image from book
a.     infile salesrep;
b.    infile salesrep ':';
c.     infile salesrep dlm;
d.    infile salesrep dlm=':';
Which of the following raw data files can be read by using the MISSOVER option in the INFILE statement? Missing values are indicated with colored blocks.
a.        
Image from book
b.      
Image from book
c.       
Image from book
d.      
Image from book
Which SAS program correctly reads the data in the raw data file that is referenced by the fileref Volunteer?
Image from book
a.     data perm.contest;
b.       infile volunteer;
c.        input FirstName $ LastName $ Age School $ Class;
d.    run;
  
e.     data perm.contest; 
f.         infile volunteer;
g.       length LastName $ 11;
h.       input FirstName $ lastname $ Age School $ Class;
i.      run;
j.      data perm.contest; 
k.        infile volunteer;
l.         input FirstName $ lastname $ Age School $ Class;
m.      length LastName $ 11;
n.    run;
o.    data perm.contest; 
p.       infile volunteer; 
q.       input FirstName $ LastName $ 11. Age School $ Class;
r.     run;
Which type of input should be used to read the values in the raw data file that is referenced by the fileref University?
Image from book
a.     column
b.    formatted
c.     list
d.    modified list
Which SAS statement correctly reads the values for Flavor and Quantity? Make sure the length of each variable can accommodate the values that are shown.
Image from book
a.     input Flavor & $9. Quantity : comma.;
b.    input Flavor & $14. Quantity : comma.;
c.     input Flavor : $14. Quantity & comma.;
d.    input Flavor $14. Quantity : comma.;
Which SAS statement correctly reads the raw data values in order and assigns them to these corresponding variables: Year (numeric), School (character), Enrolled (numeric)?
Image from book
a.     input Year School & $27.
b.          Enrolled : comma.;
c.      input Year 1-4 School & $27.
d.          Enrolled : comma.;
e.      input @1 Year 4. +1 School & $27.
f.            Enrolled : comma.;
g.    all of the above
SAS date values are the number of days since which date?
a.     January 1, 1900
b.    January 1, 1950
c.     January 1, 1960
d.    January 1, 1970
A great advantage of storing dates and times as SAS numeric date and time values is that
a.     they can easily be edited.
b.    they can easily be read and understood.
c.     they can be used in text strings like other character values.
d.    they can be used in calculations like other numeric values.
SAS does not automatically make adjustments for daylight saving time, but it does make adjustments for
a.     leap seconds
b.    leap years
c.     Julian dates
d.    time zones
An input data file has date expressions in the form 10222001. Which SAS informat should you use to read these dates?
a.     DATE6.
b.    DATE8.
c.     MMDDYY6.
d.    MMDDYY8.
The minimum width of the TIMEw. informat is
a.     4
b.    5
c.     6
d.    7
Shown below are date and time expressions and corresponding SAS datetime informats. Which date and time expresssion cannot be read by the informat that is shown beside it?
a.     30May2000:10:03:17.2 DATETIME20.
b.    30May00 10:03:17.2 DATETIME18.
c.     30May2000/10:03 DATETIME15.
d.    30May2000/1003 DATETIME14.
What is the default value of the YEARCUTOFF= system option?
a.     1920
b.    1910
c.     1900
d.    1930
Suppose your input data file contains the date expression 13APR2009. The YEARCUTOFF= system option is set to 1910. SAS will read the date as
a.     13APR1909
b.    13APR1920
c.     13APR2009
d.    13APR2020
Suppose the YEARCUTOFF= system option is set to 1920. An input file contains the date expression 12/08/1925, which is being read with the MMDDYY8. informat. Which date will appear in your data?
a.     08DEC1920
b.    08DEC1925
c.     08DEC2019
d.    08DEC2025
Suppose your program creates two variables from an input file. Both variables are stored as SAS date values: FirstDay records the start of a billing cycle, and LastDay records the end of that cycle. The code for calculating the total number of days in the cycle would be
a.     TotDays=lastday-firstday;
b.    TotDays=lastday-firstday+1;
c.     TotDays=lastday/firstday;
d.    You cannot use date values in calculations.
You can position the input pointer on a specific record by using
a.     column pointer controls.
b.    column specifications.
c.     line pointer controls.
d.    line hold specifiers.
Which pointer control is used to read multiple records sequentially?
a.     @n
b.    +n
c.     /
d.    all of the above
Which pointer control can be used to read records non-sequentially?
a.     @n
b.    #n
c.     +n
d.    /
Which SAS statement correctly reads the values for Fname, Lname, Address, City, State, and Zip in order?
Image from book
a.     input Fname $ Lname $ /
b.           Address $20. /
c.           City $ State $ Zip $;
d.    input Fname $ Lname $ /;
e.             Address $20. /;
f.            City $ State $ Zip $;
g.    input / Fname $ Lname $
h.           / Address $20.
i.             City $ State $ Zip $;
j.      input / Fname $ Lname $;
k.             / Address $20.;
l.            City $ State $ Zip $;
Which INPUT statement correctly reads the values for ID in the fourth record, then returns to the first record to read the values for Fname and Lname?
Image from book
a.     input #4 ID $5.
b.          #1 Fname $ Lname $;
c.      input #4 ID $ 1-5
d.          #1 Fname $ Lname $;
e.      input #4 ID $
f.            #1 Fname $ Lname $;
g.    all of the above
How many records will be read for each iteration of the DATA step?
Image from book
data spring.sportswr;
    infile newitems;
    input #1 Item $ Color $
          #3 @8 Price comma6.
          #2 Fabric $
          #3 SKU $ 1-6;
run;
a.     one
b.    two
c.     three
d.    four
Which INPUT statement correctly reads the values for City, State, and Zip?
Image from book
a.     input #3 City $ State $ Zip $;
b.    input #3 City & $11. State $ Zip $;
c.     input #3 City $11. +2 State $2. + 2 Zip $5.;
d.    all of the above
Which program does not read the values in the first record as a variable named Item and the values in the second record as two variables named Inventory and Type?
Image from book
a.     data perm.supplies;
b.        infile instock pad;
c.         input Item & $16. /
d.              Inventory 2. Type $8.;
e.     run;
f.      data perm.supplies;
g.        infile instock pad;
h.        input Item & $16.
i.                 / Inventory 2. Type $8.;
j.      run;
k.     data perm.supplies;
l.          infile instock pad;
m.       input #1 Item & $16.
n.              Inventory 2. Type $8.;
o.    run;
p.    data perm.supplies;
q.       infile instock pad;
r.        input Item & $16.
s.               #2 Inventory 2. Type $8.;
t.      run;
Which INPUT statement reads the values for Lname, Fname, Department, and Salary (in that order)?
Image from book
a.      input #1 Lname $ Fname $ /
b.          Department $12. Salary comma10.;
c.     input #1 Lname $ Fname $ /
d.          Department : $12. Salary : comma.;
e.     input #1 Lname $ Fname $
f.            #2 Department : $12. Salary : comma.;
g.    both b and c
Which raw data file poses potential problems when you are reading multiple records for each observation?
a.       
Image from book
b.      
Image from book
c.       
Image from book
d.      
Image from book
Which is true for the double trailing at sign (@@)?
a.     It enables the next INPUT statement to read from the current record across multiple iterations of the DATA step.
b.    It must be the last item that is specified in the INPUT statement.
c.     It is released when the input pointer moves past the end of the record.
d.    All of the above.
A record that is being held by a single trailing at sign (@) is automatically released when
a.     the input pointer moves past the end of the record.
b.    the next iteration of the DATA step begins.
c.     another INPUT statement that has a single trailing at sign (@) executes.
d.    another value is read from the observation.
Which SAS program correctly creates a separate observation for each block of data?
Image from book
a.     ata perm.produce;
b.        infile fruit;
c.         input Item $4. Variety : $10.;
d.    run;
e.     data perm.produce;
f.         infile fruit;
g.       input Item $4. Variety : $10. @;
h.    run;
i.      data perm.produce;
j.          infile fruit;
k.         input Item $ Variety : $10. @@;
l.      run;
m.   data perm.produce;
n.       infile fruit @@;
o.       input Item $4. Variety : $10.;
p.    run;
Which SAS program segment reads the values for ID and holds the record for each value of Quantity, so that three observations are created for each record?
Image from book
a.     data work.sales;
b.        infile unitsold;
c.          input ID $;
d.         do week=1 to 3;
e.             input Quantity : comma.;
f.              output;
g.         end;
h.    run;
i.      data work.sales;
j.           infile unitsold;
k.          input ID $ @@;
l.           do week=1 to 3;
m.           input Quantity : comma.;
n.            output;
o.         end;
p.    run;
q.    data work.sales;
r.          infile unitsold;
s.          input ID $ @;
t.           do week=1 to 3;
u.            input Quantity : comma.;
v.             output;
w.         end;
x.     run;
y.     data work.sales;
z.          infile unitsold;
aa.       input ID $ @;
bb.       do week=1 to 3;
cc.          input Quantity : comma. @;
dd.          output;
ee.       end;
ff.    run;
Which SAS statement repetitively executes several statements when the value of an index variable named Count ranges from 1 to 50, incremented by 5?
a.     do count=1 to 50 by 5;
b.    do while count=1 to 50 by 5;
c.     do count=1 to 50 + 5;
d.    do while (count=1 to 50 + 5);
Which option below, when used in a DATA step, writes an observation to the data set after each value for Activity has been read?
a.     do choice=1 to 3;
b.       input Activity : $10. @;
c.        output;
d.    end;
e.     run;
f.      do choice=1 to 3;
g.       input Activity : $10. @;
h.    end;
i.      output;
j.      run;
k.     do choice=1 to 3;
l.         input Activity : $10. @;
m.   end;
n.    run;
o.    a and b
Which SAS statement repetitively executes several statements while the value of Cholesterol is greater than 200?
a.     do cholesterol > 200;
b.    do cholesterol gt 200;
c.     do while (cholesterol > 200);
d.    do while cholesterol > 200;
Which choice below is an example of a Sum statement?
a.     totalpay=1;
b.    totalpay+1;
c.     totalpay*1;
d.    totalpay by 1;
Which program creates the SAS data set Perm.Topstore from the raw data file shown below?
Image from book
SAS Data Set Perm.Topstore
Store
Sales
Month
1001
77163.19
1
1001
76804.75
2
1001
74384.27
3
1002
76612.93
1
1002
81456.34
2
1002
82063.97
3
1003
82185.16
1
1003
79742.33
2
a.     data perm.topstores;
b.       infile sales98 missover;
c.        input Store Sales : comma. @;
d.       do while (sales ne .);
e.           month + 1;
f.            output;
g.          input sales : comma. @;
h.       end;
i.      run;
j.       
k.     data perm.topstores;
l.         infile sales98 missover;
m.      input Store Sales : comma. @;
n.       do while (sales ne .);
o.          Month=0;
p.          month + 1;
q.          output;
r.           input sales : comma. @;
s.        end;
t.      run;
u.     
v.     data perm.topstores;
w.       infile sales98 missover;
x.        input Store Sales : comma. Month @;
y.        do while (sales ne .);
z.           month + 1;
aa.        input sales : comma. @;
bb.     end;   
cc.     output;
dd.  run;
ee.   
ff.    data perm.topstores;
gg.     infile sales98 missover;
hh.     input Store Sales : comma. @;
ii.       Month=0;
jj.       do while (sales ne .);
kk.        month + 1;
ll.          output;
mm.           input sales : comma. @;
nn.     end;
oo.  run;
How many observations are produced by the DATA step that reads this external file?
Image from book
a.     3
b.    5
c.     12
d.    15


439. When you write a DATA step to create one observation per detail record you need to
a. distinguish between header and detail records.
b. keep the header record as part of each observation until the next header record is encountered
c. hold the current value of each record type so that the other values in the record can be read
d. all of the above.
440. Which SAS statement checks for the condition that Record equals C and executes a single statement to read the values for Amount?
a. if record=c then input @3 Amount comma7.;
b. if record=’C’ then input @3 Amount comma7.;
c. if record=’C’ then do input @3 Amount cpmma7.;
d. if record=C then do input @3 Amount comma7.;
441. Which is true for the following statements (X indicates a header record)?
         If code=’X’ then do;
         If _n_>1 then output;
         Total=0;
         Input Name $ 3-20;
        End;
    1. _N_ equals the number of times the DATA step has begun to execute.
    2. When code=’X’ and _n_  > 1 are true, an OUTPUT statement is executed.
    3. Each header record causes an observation to be written to the data set.
    4.   a and b
442. What happens when the condition type=’P’ is false?
         If type=’P’ then input @3 ID $5. @9 Address $20.;
         Else if type=’V’ then input @3 Charge 6.;
  1. The values for ID and Address are read.
  2. The values for charge are read.
  3. Type is assigned the value of V.
  4. The ELSE statement is executed.
443. What happens when last has a value other than zero?
             Data perm.househld (drop=code);
                Infile citydata end=last;
                Retain Address;
               Input type $1. @;
               If code=’A’ then do;
                  If _n_ > 1 then output;
                  Total=0;
                  Input address $ 3-17;
                 End;
                Else if code=’N’ then total+1;
                 If last then output;
                 Run;
    1. Last has a value of 1.
    2. The OUTPUT statement writes the last observation to the data set.
    3. The current value of Last is written to the data set.
    4. A and B.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.