Hello!
I need to extract a medication class that is between two delimiters that are the same. In this case, it is a semi-colon (;).
have (oldvar) = ATC|R|RESPIRATORY SYSTEM; ATC|R03|DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES; ATC|R03A|ADRENERGICS, INHALANTS; ...
want (newvar) = ATC|R03|DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES
can you suggest an effective way to do this?
Thank you!
is it always in 2nd position?
if yes, extract the 2nd
data test;
have='ATC|R|RESPIRATORY SYSTEM; ATC|R03|DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES; ATC|R03A|ADRENERGICS, INHALANTS; ATC|R03AC|SELECTIVE BETA-2-ADRENORECEPTOR AGONISTS; PRODUCT|001395 01 001|SALBUTAMOL; PRODUCTSYNONYM|001395 01 002|VENTOLIN /00139501/;';
want=strip(scan(have,2,';'));
run;
do you mean this?
data test;
have=' ATC|R|RESPIRATORY SYSTEM; ATC|R03|DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES';
want=scan(have,-1,';','m');
run;
or just this?
data test;
have=' ATC|R|RESPIRATORY SYSTEM; ATC|R03|DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES';
want=scan(have,-1,';');
run;
Thanks for the quick response!
I should have included the entire length of the string which is as follows:
ATC|R|RESPIRATORY SYSTEM; ATC|R03|DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES; ATC|R03A|ADRENERGICS, INHALANTS; ATC|R03AC|SELECTIVE BETA-2-ADRENORECEPTOR AGONISTS; PRODUCT|001395 01 001|SALBUTAMOL; PRODUCTSYNONYM|001395 01 002|VENTOLIN /00139501/;
is it always in 2nd position?
if yes, extract the 2nd
data test;
have='ATC|R|RESPIRATORY SYSTEM; ATC|R03|DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES; ATC|R03A|ADRENERGICS, INHALANTS; ATC|R03AC|SELECTIVE BETA-2-ADRENORECEPTOR AGONISTS; PRODUCT|001395 01 001|SALBUTAMOL; PRODUCTSYNONYM|001395 01 002|VENTOLIN /00139501/;';
want=strip(scan(have,2,';'));
run;
It will always be between the first and second semi-colon.
ok, i updated in my previous. check that out plz
here again
data test;
have='ATC|R|RESPIRATORY SYSTEM; ATC|R03|DRUGS FOR OBSTRUCTIVE AIRWAY DISEASES; ATC|R03A|ADRENERGICS, INHALANTS; ATC|R03AC|SELECTIVE BETA-2-ADRENORECEPTOR AGONISTS; PRODUCT|001395 01 001|SALBUTAMOL; PRODUCTSYNONYM|001395 01 002|VENTOLIN /00139501/;';
want=strip(scan(have,2,';'));
run;
It worked. 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.