Hello everyone, I have a variable which contains items such as:
1. Symptoms, signs, and abnormal clinical and laboratory findings
2. Injury and poisoning
I only want to keep the character portion:
Symptoms, signs, and abnormal clinical and laboratory findings
Injury and poisoning
Could someone please help me?
If you know that every value has that numeric prefix then just remove the first "word".
want=left(substrn(string,1+length(scan(string,1,' '))));
Otherwise you will have to work harder first to figure out if the string does have the prefix.
data have ;
input string $CHAR80. ;
cards4;
1. Symptoms, signs, and abnormal clinical and laboratory findings
2. Injury and poisoning
;;;;
data want ;
set have;
new_string = prxchange('s/^ *\d+\. +(.*)$/\1/',1,string);
run;
This method does not remove the . as well ?
@luvscandy27 wrote:
This method does not remove the . as well ?
Please give us a complete description of the problem. Show us representative examples.
I would find the first period and remove from there onwards using substring.
Compress may inadvertenly remove any other numeric/periods.
However, these were likely used to order the data so assuming you don't need that you'll be fine.
x=findc(variable, '.');
want = substr(variable, x);
If you know that every value has that numeric prefix then just remove the first "word".
want=left(substrn(string,1+length(scan(string,1,' '))));
Otherwise you will have to work harder first to figure out if the string does have the prefix.
data have ;
input string $CHAR80. ;
cards4;
1. Symptoms, signs, and abnormal clinical and laboratory findings
2. Injury and poisoning
;;;;
data want ;
set have;
new_string = prxchange('s/^ *\d+\. +(.*)$/\1/',1,string);
run;
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: