BookmarkSubscribeRSS Feed
wisej
Calcite | Level 5

Hi,

 

I am using a macro to run PROC FREQs for a descriptive statistics table to be used in a paper. I am trying to run the same PROC FREQ for different IDs, so I am using a where statement within the macro. The code I am using is pasted below - when I run this code, SAS tells me "keyword parameter ID was not defined within the macro." I appreciate any help!!

 

%macro analysis(dataset,variable,condition);
proc freq data=&dataset;
tables &variable;
where &condition;
run;
%mend analysis;
%analysis(biweekly,amount_food_consumed,ID="LION-1");

2 REPLIES 2
Tom
Super User Tom
Super User

The macro call:

%analysis(biweekly,amount_food_consumed,ID="LION-1");

Is referencing a macro parameter named ID, but the macro does not define a parameter named id.

Call the CONDITION parameter by name instead.

%analysis(biweekly,amount_food_consumed,condition=ID="LION-1");

Or add parentheses into the condition value. 

%analysis(biweekly,amount_food_consumed,(ID="LION-1"));

 

wisej
Calcite | Level 5

That worked - thank you so much!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 517 views
  • 0 likes
  • 2 in conversation