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 Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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