BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Batman
Quartz | Level 8

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
%put %scan(%superQ(&Sel_Ing4),1,%str(,));

 

I think you need %bquote and not %superq

 

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
%put %scan(%superQ(&Sel_Ing4),1,%str(,));

 

I think you need %bquote and not %superq

 

 

--
Paige Miller
Batman
Quartz | Level 8

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 549 views
  • 0 likes
  • 2 in conversation