BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi, I need to pass the cat1 variable into the in statement, but the macro doesn't like the commas. how can i pass multiple verticals in the same variable?

%macro cat(cat1, cat=);

data &cat;
set lastqcomp;
where vertical in (&cat1);
run;

%mend cat;

%cat(cat1='Apparel, Accessories & Footwear','Other','Toys' cat=allvert);
1 REPLY 1
Dale
Pyrite | Level 9
This should be posted in the forum "SAS Macro Facility, Data Step and SAS Language Elements". It has nothing to do with SAS Statistical Procedures.

That said, you should be able to pass the string for cat1 by using the %str() macro quoting function.

%cat(cat1=%str('Apparel, Accessories & Footwear','Other','Toys'), cat=allvert);


I would note that your %macro statement names cat1 as a positional parameter and cat as a keyword parameter. However, your invocation shows that you intend to use cat1 as a keyword parameter. Code which is consistent for both macro definition and invocation would be:

%macro cat(cat1=, cat=);

data &cat;
set lastqcomp;
where vertical in (&cat1);
run;

%mend cat;

%cat(cat1=%str('Apparel, Accessories & Footwear','Other','Toys'), cat=allvert);

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1111 views
  • 0 likes
  • 2 in conversation