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.
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
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.
Yes, just noticed your raw input. You would need delimiter to correctly apply list input.
Haikuo
Thanks everyone for your inputs.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.