The contents of the raw data file SIZE are listed below:
--------10-------20-------30
72 95
The following SAS program is submitted:
data test;
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)
Click Comment link to get answer
The answer is A
ReplyDeleteAnswer A
ReplyDeleteAns A;
ReplyDeleteSince there is no period after weight2(weight2.) the pointer will move to column 2
The answer is D i.e Missing Value. As the period is missing, the length of the variable is assigned as 2 and a missing value is assigned as SAS is unable to read the value using the specified informat.
ReplyDeleteA is the answer, kindly run your program and you will come to know
DeleteAnswer is A.....as the weight has no dot after 2 it moves to the pointer to column 2.
ReplyDeleteD is correct ...because of invalid informat of weight
ReplyDeleteA is the answer, kindly run your program and you will come to know
DeleteThe answer is A. Since the 2. is not specified correctly, it considers 2 as column input and moves the pointer to column 2.
ReplyDeletealso remember, if you just specified @4 weight;
it would still be ok and it will give the correct value 95.
Why is it still be value 95 if we just specified @4 weight? SAS treat the weight as column input? formatted input? or list input?
DeleteFormatted input
DeleteAnswer A not D,just tried it
ReplyDeleteAnswer is A
ReplyDeleteAnswer is D , Just tried it and as per the SAS online document, any variable declared without proper informat will produce a missing value, a '.' for numeric ans space for character .
ReplyDeleteAnswer is D
ReplyDeleteanswer is A.
ReplyDeleteanonymous is Ans A only...
ReplyDeletejust tried, ans is A (the pointer moves to the 2nd column)
ReplyDeleteIf Answer is A, can you give us the logic to support it. Why pointer moves to 2nd column?
ReplyDeletesakar
Sakar. I got my sas program and ran it differently;
ReplyDeletedata test;
input @ 1 height 2 @ 4 weight 2 ;
cards;
72 95
;
run;
Log:There were 1 observations read from the data set WORK.TEST.
output;
Obs height weight
1 2 2
Look the mistry I found is if put dot sign gives different answer.
data test;
input @ 1 height 2. @ 4 weight 2. ;
cards;
72 95
;
OUTPUT.
Obs height weight
1 72 95
I DO NOT HAVE THE LOGIC BEHIND IT AND MAY BE SOMEBODY CAN EXPLAIN IT. WHY THAT DOT MAKES DIFFERENT.
I GUESS IF YOU HAVE A COLUMN INPUT STATEMENT LIKE THIS.
INPUT @ 1 HEIGHT 2. $4 WEIGHT 5 ;
IT MISLEADS THE LOGIC AND PUT THE 5 WITHOUT DOT AFTER 5 ( 5.) IT MAY NOT BE ASKING TO TAKE 5 SPACE OR WIDTH AFTER BUT PUT 5
Let us know what it is.
The Informat must end with a dot(.)
Deleteotherwise sas would think 2 is the value of the weight.
Use 2. as the informat instead of 2
I got the answer sakar.
ReplyDeleteinput @ 1 height 2 @ 4 weight 4;
cards;
72 95
;
In this case the @4 it will put the value from the column 4 which is 9. So to assign 2 space we must add 2. or if we want to assign 3 space it should be 3.
I think the answer should be D. I reffered the book and it says when using formatted input if we forget to add period (.) after the value it assigns it that length for the variable.
ReplyDelete"Remember to specify the period in the informat name. For example, if you omit the period in the following INPUT statement, SAS assigns a length of 3 to JobTitle instead of reading JobTitle with the 3. informat.
input @9 FirstName $5. @1 LastName $7. +7 JobTitle 3;"
Please correct me if iam wrong..
If I may ask, which book did you consult?
DeleteA
ReplyDeleteA is correct
ReplyDeleteAnswer is A. Tried it with 2 and 4. With 2 the weight is 2 and with 4 is 9.
ReplyDeletedata afifi;
ReplyDeleteinfile "afifi.dat";
input
#1 @1 idnum 4.0 @5 age 4.0 @13 sex 3. @16 surv 1.
@17 shoktype 4. @21 sbp1 4. @69 hgb1 4.1
#2 @21 sbp2 4. @69 hgb2 4.1;
run;
Note that the format 4.0 is equivalent to the format 4. It is critical that the format be given with a period after it (e.g. 4. rather than 4 ), because that allows SAS to distinguish between a format and a column location.
in such cases where first variable is directed by @ column pointer if informat for subsequent variables are incorrect ( for eg. @ 4 weight 2 instead of @ 4 weight 2. )
ReplyDeletethen SAS takes that incorrect format value eg. 2 as column pointer and reads value starting from 1st column.
for eg. in above case if weight is informated as @4 weighti 2, SAS starts reading from 1st column and assigns the value to var weight, the one present in the 2nd column;
would like 2 add in above comment that SAS works differently if the raw data file has caracter variable in its beginning eg. starting from coloumn 1. In this case sas returns missing value after reading the subsequent numeric value with wrong informat.
ReplyDeleteYes, the answer is A. Cause missing a point after the 2nd "2". As a result, SAS misunderstand "2" as "line 2", not the length of WEIGHT
ReplyDeletewith 1 it would be 7
ReplyDeletewith 2 it would be 2
with 3 it would be .
with 4 it would be 9
with 5 it would be 5
A, tried and verified, it is A
ReplyDeletegm;;
ReplyDeleteAns A;
Since there is no period after weight2(weight2.) the pointer will move to column 2
A
ReplyDeleteThe Answer is A,
ReplyDeleteheight is taken as 72. Then weight will be 4 places after that so the value will be 2. Is it correct?
I agree with sharad's reasoning , the answer is B
ReplyDeletegclub
gclub casino online
The War Pass costs 950 V-Bucks also, within the product store, companies and emotes tend to cost between 1500 and 500. may turn out paying more good currency exchange rate. salsaroc.com
ReplyDeleteGreat article,Thank You,,,
ReplyDeleteKeep Updating...
MSBI Online Course