How do I exclude numbers from an observation?
For example, I want "Brown, Jack" instead of "Brown, Jack 01".
Thank you.
You'll have to provide an example with data and code where that happens. It doesn't happen in the following test:
data have;
length name $30;
input;
name=_infile_;
cards;
Smith, John 12
Jones, John 12
Smith, Mary 14
Howard, Wilburt 3rd 19
;
data want;
set have;
name=compress(name,,'d');
run;
have a look at the modifiers for the compress() function
The modifier 'ak' removes the numbers, but I lose the comma.
If I use 'd' I lose all spaces.
How do I keep spaces and commas?
Thank you.
Don't use the k modifier. Only use the d modifier. That way you will drop all of the digits.
If I use this compress(reported_by,'','d')
then I lose spaces as well as digits.
You'll have to provide an example with data and code where that happens. It doesn't happen in the following test:
data have;
length name $30;
input;
name=_infile_;
cards;
Smith, John 12
Jones, John 12
Smith, Mary 14
Howard, Wilburt 3rd 19
;
data want;
set have;
name=compress(name,,'d');
run;
I changed compress(reported_by,'','d') to compress(reported_by,,'d'). Thank you.
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!
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.