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()
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.