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.

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