The contents of the raw data file SIZE are listed below:
--------10-------20-------30
72 95
72 95
The following SAS program is submitted:
data test;
infile 'size';
input @1 height 2. @4 weight 2;
run;
infile 'size';
input @1 height 2. @4 weight 2;
run;
Which one of the following is the value of the variable WEIGHT in the output data set?
A. 2
B. 72
C. 95
D. . (missing numeric value)
A. 2
B. 72
C. 95
D. . (missing numeric value)
5 comments:
Answer: A
The start column for weight has been mentioned as 2… So SAS reads in 2 in the value of 72
Execute this and c for yourself…the answers are 2,0,1 for each observations..
data work.TEST;
infile cards;
input @1 height 2. @4 weight 2;
cards;
72 95
60 91
11 22
;
run;
eventhough the start column for weight says @4, sas still thinks 2 is the start column? why is that?
The 2 after weight needs a period following it to create a weight value of 95.
data work.TEST1;
infile cards;
input @1 height 2. @4 weight 1;put _all_;
cards;
72 95
60 91
13 22
;
height=72 weight=7 _ERROR_=0 _N_=1
height=60 weight=6 _ERROR_=0 _N_=2
height=13 weight=1 _ERROR_=0 _N_=3
actually weight 1 considers column 1 of raw data file or datalines
if i consider weight 3 then
data work.TEST1;
infile cards;
input @1 height 2. @4 weight 3;put _all_;
cards;
72 95
60 91
13 22
;
height=72 weight=. _ERROR_=0 _N_=1
height=60 weight=. _ERROR_=0 _N_=2
height=13 weight=. _ERROR_=0 _N_=3
then it gives missing values , since in column 3 is blank
data work.TEST1;
infile cards;
input @1 height 2. @4 weight 2;put _all_;
cards;
height=72 weight=2 _ERROR_=0 _N_=1
height=60 weight=0 _ERROR_=0 _N_=2
height=13 weight=3 _ERROR_=0 _N_=3
data work.TEST;
infile cards;
input @1 height 2. @4 weight 2.;
cards;
72 95
60 91
11 22
;
run;
this gives weight 95,91,22
Post a Comment