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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 15 replies
  • 3962 views
  • 3 likes
  • 5 in conversation