BookmarkSubscribeRSS Feed
andreas_lds
Jade | Level 19

@ballardw wrote:

Unfortunately parsing _infile_ may require a bit more work depending on the actual content of the data.

 

Consider:

data junk;
   infile datalines dlm=',';
   input;
   put _infile_;
   Name = scan(_infile_, 1, ",");
   Age = input(scan(_infile_, 3, ","), best.);
datalines;
"Jones, Smith",23
;
run;

The put was included so we can see that _infile_ behaves as expected with datalines input. The kicker is that the name is truncated but does read the age for this one.

 

@sks521 really needs to post example data if one of the posted solutions hasn't worked.

 


 

Using Q as third argument in scan should solve such issues. Adding M to the third parameter helps, if some variable could be missing.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 15 replies
  • 6272 views
  • 3 likes
  • 5 in conversation