I just wanted to read this data only using List input style ....I am not able to read it?
I tried this..
data test;
infile datalines missover;
input name $ age sal;
cards;
dharmu 25 40000
john 450000
dharmu 26 40001
dharmu 25 40002
25 40003
;
run;
proc print;run;
output-
SAS Output
dharmu | 25 | 40000 |
john | . | 450000 |
dharmu | 25 | 40001 |
dharmu | 25 | 40002 |
25 | 40003 | . |
Like this?
data WANT;
infile datalines ;
input;
SCAN=1;
if _infile_ ne: ' ' then do;
NAME=scan(_infile_,1);
SCAN+1;
end;
if 1 <= input(scan(_infile_,SCAN),3.) <= 120 then do;
AGE=input(scan(_infile_,SCAN),3.) ;
SCAN+1;
end;
SAL=input(scan(_infile_,SCAN),8.) ;
cards;
dharmu 25 40000
john 450000
peter 26 40001
Sue 25 40002
25 40003
25 40003
25
;
run;
You need to use the period as a place holder for missing values in midde and start. MISSOVER will handle missing at the end but you can as mark those as well.
If your data cannot be modified you will have to come up with a scheme that allows you to figure which field is missing.
For example:
You get the idea but it will be a bit messy.
Like this?
data WANT;
infile datalines ;
input;
SCAN=1;
if _infile_ ne: ' ' then do;
NAME=scan(_infile_,1);
SCAN+1;
end;
if 1 <= input(scan(_infile_,SCAN),3.) <= 120 then do;
AGE=input(scan(_infile_,SCAN),3.) ;
SCAN+1;
end;
SAL=input(scan(_infile_,SCAN),8.) ;
cards;
dharmu 25 40000
john 450000
peter 26 40001
Sue 25 40002
25 40003
25 40003
25
;
run;
Thank you so much....
I am getting the right data but still I will try to understand the code...
being new into the system this code is complex to me but this is what I expected to.
Thanks!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.