Hope someone can help me.
I would like to call a macro from within another macro but only every time 'category' changes, and then pass the initiate macro the value of a variable sorted_profile_table.
I have spent hours on this and all the help online isn't helping, thank you for your assistance!
Here is the code (pseudocode in some cases):
%macro load_control_tables;
proc sort data=profile_table out=sorted_profile_table;
by category;
run;
data _null_;
set sorted_profile_table ;
by category;
if first.category then
do;
call another macro (called %initiate) using the VALUE of a VARIABLE from sorted_profile_table (as a macro variable)
end;
run;
%mend;
The macro @initiate is within another program and has been run.
Thanks folks!
Mark
You need Call execute
Please refer to the technical paper by the genius none other than Ian whitlock
http://www2.sas.com/proceedings/sugi22/CODERS/PAPER70.PDF
You need Call execute
Please refer to the technical paper by the genius none other than Ian whitlock
http://www2.sas.com/proceedings/sugi22/CODERS/PAPER70.PDF
Hello there,
Subsequent to this, what if the parameters to a macro call are longer than 262 characters, it seems CALL EXECUTE fails in this case?
Kind regards,
Mark
If your having parameters that long then consider re-working your process. There is never a need to use macros, just change the way of thinking about things. One of the main things we see pop up here is people passing in lists of items. Take this example, you need to filter off a list of items, you could put those items in a macro parameter like:
%macro filter (list=); proc sql; select * from have where myvar in (&list.); quit; %mend filter;
Now if your list grows this type of thing can get unwieldy and hard to program with. Use the power of datasets makes this far simpler, just with a simple change of thinking:
%macro filter (listds=); proc sql; select * from have where myvar in (select var from &listds.); quit; %mend filter;
In this instance we have a dataset with our values, and pass that into the macro, the dataset can be any size and be used just like any other dataset.
With regards to the "longer than 262 characters, it seems CALL EXECUTE fails in this case?" - what do you mean fails? What happens, what is in the log etc. Do you mean you get a warning about length, if so there is: options noquotelenmax; which will turn off that warning, make sure to turn it back on afterwards.
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.