ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 13

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

39 comments:

  1. Anonymous1:08 AM

    The answer is A

    ReplyDelete
  2. Ans A;

    Since there is no period after weight2(weight2.) the pointer will move to column 2

    ReplyDelete
  3. Anonymous1:56 AM

    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.

    ReplyDelete
    Replies
    1. A is the answer, kindly run your program and you will come to know

      Delete
  4. Answer is A.....as the weight has no dot after 2 it moves to the pointer to column 2.

    ReplyDelete
  5. D is correct ...because of invalid informat of weight

    ReplyDelete
    Replies
    1. A is the answer, kindly run your program and you will come to know

      Delete
  6. swapna7:35 PM

    The answer is A. Since the 2. is not specified correctly, it considers 2 as column input and moves the pointer to column 2.
    also remember, if you just specified @4 weight;
    it would still be ok and it will give the correct value 95.

    ReplyDelete
    Replies
    1. 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?

      Delete
    2. Anonymous6:22 AM

      Formatted input

      Delete
  7. Anonymous9:10 PM

    Answer A not D,just tried it

    ReplyDelete
  8. Anonymous3:43 PM

    Answer is A

    ReplyDelete
  9. Anonymous3:20 AM

    Answer 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 .

    ReplyDelete
  10. Anonymous1:51 PM

    Answer is D

    ReplyDelete
  11. Anonymous10:57 AM

    answer is A.

    ReplyDelete
  12. Anonymous12:14 PM

    anonymous is Ans A only...

    ReplyDelete
  13. Anonymous4:16 AM

    just tried, ans is A (the pointer moves to the 2nd column)

    ReplyDelete
  14. Anonymous10:35 AM

    If Answer is A, can you give us the logic to support it. Why pointer moves to 2nd column?

    sakar

    ReplyDelete
  15. Anonymous9:07 PM

    Sakar. I got my sas program and ran it differently;
    data 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.

    ReplyDelete
    Replies
    1. The Informat must end with a dot(.)
      otherwise sas would think 2 is the value of the weight.
      Use 2. as the informat instead of 2

      Delete
  16. Anonymous1:57 PM

    I got the answer sakar.

    input @ 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.

    ReplyDelete
  17. Anonymous8:47 PM

    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.
    "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..

    ReplyDelete
    Replies
    1. Anonymous4:03 AM

      If I may ask, which book did you consult?

      Delete
  18. A is correct

    ReplyDelete
  19. Answer is A. Tried it with 2 and 4. With 2 the weight is 2 and with 4 is 9.

    ReplyDelete
  20. Anonymous6:07 PM

    data afifi;
    infile "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.

    ReplyDelete
  21. Meenal11:26 AM

    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. )
    then 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;



    ReplyDelete
  22. Meenal11:37 AM

    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.

    ReplyDelete
  23. Yes, 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

    ReplyDelete
  24. Anonymous11:50 AM

    with 1 it would be 7
    with 2 it would be 2
    with 3 it would be .
    with 4 it would be 9
    with 5 it would be 5

    ReplyDelete
  25. A, tried and verified, it is A

    ReplyDelete
  26. Anonymous5:34 PM

    gm;;
    Ans A;

    Since there is no period after weight2(weight2.) the pointer will move to column 2

    ReplyDelete
  27. The Answer is A,
    height is taken as 72. Then weight will be 4 places after that so the value will be 2. Is it correct?

    ReplyDelete
  28. I agree with sharad's reasoning , the answer is B
    gclub
    gclub casino online

    ReplyDelete
  29. 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

    ReplyDelete
  30. Great article,Thank You,,,
    Keep Updating...

    MSBI Online Course

    ReplyDelete