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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 4627 views
  • 3 likes
  • 5 in conversation