Could somebody help me with passing numeric value to the Macro variable...
example :
%MACRO1(TPM=1000,X1=TEST);
%MACRO MACRO1(TPM,X1);
%PUT "This is the value of &TPM";
%MEND MACRO1;
However as i understand Macro take only Text how do i make sure it has numeric value inside of the macro while execution.?
How are you using the macro variable? It depends on the situation, but you could do a check in your macro per:
%MACRO MACRO1(TPM,X1);
%if %sysfunc(anyalpha("&TPM."))>0 %then %put "Non numeric found";
%else %PUT "This is the value of &TPM";
%MEND MACRO1;
%MACRO1(TPM=a10a00,X1=TEST);
Just use the macro variable reference at any place that you would normally type the number into your code. Remember that macro is mainly just to generate code that will then be compiled and run the same as if it had been typed into the original program.
%macro loopy(start,stop);
DO i=&start TO &stop ;
PUT i=;
END;
%mend loopy;
data _null_;
%loopy(start=5, stop=10);
run;
It is only of concern if you are trying to pass a floating point number and compare its value to the value of a dataset variable. Then you might need to adjust for rounding.
Check %eval() and %sysevalf()
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!
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.