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.
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.
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.