ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 87

The contents of the raw data file TEAM are listed below:
--------10-------20-------30
Janice 10
Henri 11
Michael 11
Susan 12
The following SAS program is submitted:
data group;
infile 'team';
input name $15. age 2.;
file 'file-specification';
put name $15. +5 age 2.;
run;
Which one of the following describes the output created?
A. a raw data file only
B. a SAS data set named GROUP only
C. a SAS data set named GROUP and a raw data file
D. No output is generated as the program fails to execute due to errors.
Click Comment link to get answer

25 comments:

  1. The correct answer is C

    ReplyDelete
  2. i think the answer is D

    as we are using list input and output ...and to input a character longer than 8 bytes needs to have a colon before format

    data group;
    infile 'team';
    input name :$15. age :2.;

    ReplyDelete
    Replies
    1. Anonymous9:03 PM

      It does error however the file and data set are still created. mine ended up with 'Henri 11 ' was the only line.

      Delete
  3. Anonymous2:13 PM

    Answer is D

    ReplyDelete
  4. Anonymous2:33 PM

    can anyone please explain. thanks

    ReplyDelete
  5. Anonymous2:26 PM

    any explanation would be appreciated!!!
    thanks

    ReplyDelete
  6. infile and input statements are used to read data from raw data file. File and put statements are used to write data to raw data file. In our example later is happening, so a raw data file is created and as data step is creating a dataset (it is not data _null_), it will create an output dataset too. So the answer is C raw data file and group dataset. Hope that helps.

    ReplyDelete
  7. Anonymous11:48 AM

    YEs,it did. Answer ( c ).

    ReplyDelete
  8. Anonymous7:44 AM

    But as it is creating GROUP and a raw data,
    in their input, put statements
    doesn't the "name $15." place BOTH the name and age values of the orginal data as a single data into the name variable of the new data,file created?

    and doesn't this lead to an error, leaving variable age with nothing?

    ReplyDelete
  9. Anonymous5:56 AM

    it's a data error not a syntax error! so the program will produce the data set named GROUP and a raw data file, with some missing values.

    the answer is C

    ReplyDelete
  10. The correct answer is c:

    data group;
    infile datalines;
    input name $15. age 2.;
    file 'c:\temp\borra.txt';
    put name $15. +5 age 2.;

    datalines;
    Janice 10
    Henri 11
    Michael 11
    Susan 12
    ;
    run;

    ReplyDelete
  11. Anonymous11:18 AM

    C is the answe

    ReplyDelete
  12. I ran the prog and checked the result. A dataset with only one observation was created with the value 'Henri 11' in the first variable, and the second variable was empty. A file was also created showing the other 3 missing observations pasted in the text file.

    ReplyDelete
  13. Ans C.

    SAS data set named GROUP and a raw data file is created - jus checked in SAS.

    ReplyDelete
  14. C .. data errors dont stop the step execution ... only syntax errors do. So the dataset and the file get created with erroneous data.

    ReplyDelete
  15. Anonymous4:28 PM

    Here +5 indicates what?

    ReplyDelete
    Replies
    1. it seems this is related to what I found in this link:

      http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#n1spe7nmkmi7ywn175002rof97fv.htm

      "This statement moves the pointer to column 23, writes a value of LENGTH in columns 23 through 26, advances the pointer five columns, and writes the value of WIDTH in columns 32 through 35:

      put @23 length 4. +5 width 4.;

      Delete