I want to parse a macro value with text, spaces and slashes separated by comma delimiters. I got the code for the second %PUT statement from https://communities.sas.com/t5/SAS-Programming/How-to-scan-comma-delimited-macro-variable-list/td-p/...
However, I'm getting an error message. How can I rectify?
27 %put &sel_ing4;
DROSPIRENONE / ETHINYL ESTRADIOL / LEVOMEFOLATE CALCIUM, ETHINYL ESTRADIOL / ETHYNODIOL DIACETATE, ETHINYL ESTRADIOL /
LEVONORGESTREL, ETHINYL ESTRADIOL / NORETHINDRONE, ETHINYL ESTRADIOL / NORETHINDRONE ACETATE
28 %put %scan(%superQ(&Sel_Ing4),1,%str(,));
ERROR: Invalid symbolic variable name DROSPIRENONE ETHINYL ESTRADIOL / LEVOMEFOLATE CALCIUM, ETHINYL ESTRADIOL / ETHYNODIOL
DIACETATE, ETHINYL ESTRADIOL / LEVONORGESTREL, ETHINYL ESTRADIOL / NORETHINDRONE, ETHINYL ESTRADIOL / NORETHINDRONE ACETATE.
%put %scan(%superQ(&Sel_Ing4),1,%str(,));
I think you need %bquote and not %superq
%put %scan(%superQ(&Sel_Ing4),1,%str(,));
I think you need %bquote and not %superq
No, the delimiter is actually a comma. This is a list of active ingredient groups for the same drugs and the producer of the original data chose to join them with slashes. It originally came in a single variable in the following format (just showing two cells).
DROSPIRENONE / ETHINYL ESTRADIOL / LEVOMEFOLATE CALCIUM
ETHINYL ESTRADIOL / NORGESTIMATE
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.
Ready to level-up your skills? Choose your own adventure.