How can I pass a table column as a parameter in a macro?
Example of what I intend to do:
data xyz;
input userid;
datalines;
1
2
;
run;
%macro looper (userid);
...
...
%mend looper;
Thats exactly the way. Describe further what you problems are, test data/required output is also good.
Do you want to call %LOOPER just once, or do you want to call it for each observation in XYZ?
I want to call % LOOPER for each observation in table XYZ
data _null_;
set XYZ;
call execute('%looper ('||strip(user)||');');
run;
However there are probably better ways of doing it, but without the rest of the information its hard to say.
One again I will remind you of the importance of timing with the macro language and the fact that CALL EXECUTE has subtleties that most do NOT understand.
T
The following example uses the %NRSTR macro quoting function to mask the macro statement. This function will delay the execution of macro statements until after a step boundary.
call execute('%nrstr(%sales('||month||'))');While it may not matter for the programs that you write we have not seen the OP's program and have no idea what the OP will come up with.
Thanks; this will do it.
It would be considerate as well to explain why you want to perform such processing, as much as there may be a more effective / efficient technical approach - specifically what is your objective and how might you intend to use the SAS observation content with each macro invocation? It appears that LOOPER is intended to be a code-piece executed within the SAS DATA step you have illustrated, although you have the %MACRO %MEND definition coded after the RUN; statement which will most definitely short-circuit the processing you desire to achieve.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.