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.

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