BookmarkSubscribeRSS Feed
noviceinsas
Calcite | Level 5

my question is not how to fix the issue. I am just trying to understand the output of a program which is using modified list input for reading data. Compare the 2 problems. Both of these are using modified list input.

data survey;

     (Ques1 - Ques5) ( : $1.);

datalines;

12345

;

Output of this program was - Ques1: 1 Ques2: 2 Ques3: 3 Ques4:  4 Ques5:  5

To understand this answer, I thought even though it is using list input, it wont read until it finds the delimiter/end-of-record. Because informat is 1., pointer will stop at '2' after reading first value. Similarly, the values of rest of the variables are generated.

Based on that, I guessed that the output of the following program would be TYPE: DAISY and COLOR: YELLOW

DATA TEST1;

INFILE DATALINES TRUNCOVER;

INPUT TYPE : $5. COLOR : $11.;

DATALINES;

DAISYYELLOW

;

Thanks again for your replies.

Haikuo
Onyx | Level 15

This is code I run 20 sec ago on SAS 9.3 TS1M2:

data survey;

infile datalines truncover;

input (Ques1 - Ques5) (:$1.);

put _all_;

datalines;

12345

;

And this is the log I got:

889 data survey;

890 infile datalines truncover;

891 input (Ques1 - Ques5) (:$1.);

892 put _all_;

893 datalines;

Ques1=1 Ques2= Ques3= Ques4= Ques5= _ERROR_=0 _N_=1

NOTE: The data set WORK.SURVEY has 1 observations and 5 variables.

NOTE: DATA statement used (Total process time):

  real time 0.00 seconds

  cpu time 0.00 seconds

I don't see Ques2-Ques4 pick up any value except being missing all along. Are you sure this is the results you got from the code you run? Can you verify it again by running it? I suspected that the colon ":" is the key. Are you sure that you have that ":" in your code?, if you don't, then the World goes back to its place. 

Haikuo

noviceinsas
Calcite | Level 5

Thanks Haikuo. I don't have access to SAS so I cant run it but I ran this program few days back. may be I used formatted input and not modified list input but I think the concept is clear to me now. Modified list input will read until it encounters a delimiter/end-of-record. so if want to have correct output, we should modify the program as follows. is that correct?

data survey;

infile datalines truncover;

input (Ques1 - Ques5) (:$1.);

put _all_;

datalines;

1 2 3 4 5

;

Thanks again.

Haikuo
Onyx | Level 15

Yes, just noticed your raw input. You would need delimiter to correctly apply list input.

Haikuo

noviceinsas
Calcite | Level 5

Thanks everyone for your inputs.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 19 replies
  • 2983 views
  • 9 likes
  • 6 in conversation