BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10
 data test;
 last_name = 'stanley jr.';
 run;

 data _null_;
 file "my_file.txt" lrecl=119 TERMSTR=crlf;
 set test;
 put @1 last_name  $26.
 ;run;

The customer receiving the file runs it through an outside program
For some reason it gives an invaild character message. It appears the
period at the end of Jr is causing the invalid character. Is there a
way to truncate the period at the end of the name if it exists  to help avoid the invalid character

1 REPLY 1
ballardw
Super User

The question might be are there are any periods that you want to keep in that field.

 

Perhaps:

 data test;
 last_name = 'stanley jr.';
 last_name = compress(last_name,'.','t');
 run;

which will remove all periods in the field.

 

Data design note: JR, SR, II, III, IV, 'the third'  and such are not really part of a last name field and perhaps should be in a separate field.

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
  • 1 reply
  • 210 views
  • 0 likes
  • 2 in conversation