BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dharmendra_All_
Calcite | Level 5

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

Obs name age sal 1 2 3 4 5
dharmu2540000
john.450000
dharmu2540001
dharmu2540002
2540003

.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

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;

View solution in original post

3 REPLIES 3
data_null__
Jade | Level 19

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:

  • 2 fields and the first is numeric implies field 1 is missing
  • 2 fields and the first is char and second is numeric and out of age range implies field 2 is missing

You get the idea but it will be a bit messy.

 

ChrisNZ
Tourmaline | Level 20

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;
Dharmendra_All_
Calcite | Level 5

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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 3 replies
  • 1061 views
  • 1 like
  • 3 in conversation