%macro chk (result = );
data one;
val = "&result.";
run;
%mend chk;
%chk (result = %str(Intensity (%)) );
I need to print result for VAL variable as "Intensity (%)" ,e.g VAL = "Intensity(%)" , but not able to do it with above code.
any suggestion please.
When you use %STR(), you can mask a % with a %, so use %%. See the docs: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0pnc7p9n4h6g5n16g6js048nhfl.htm
Example Log:
1 %macro chk (result = ); 2 data one; 3 val = "&result."; 4 put val= ; 5 run; 6 %mend chk; 7 8 %chk (result = %str(Intensity (%%)) ); val=Intensity (%) NOTE: The data set WORK.ONE has 1 observations and 1 variables.
When you use %STR(), you can mask a % with a %, so use %%. See the docs: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0pnc7p9n4h6g5n16g6js048nhfl.htm
Example Log:
1 %macro chk (result = ); 2 data one; 3 val = "&result."; 4 put val= ; 5 run; 6 %mend chk; 7 8 %chk (result = %str(Intensity (%%)) ); val=Intensity (%) NOTE: The data set WORK.ONE has 1 observations and 1 variables.
For this example, you don't actually need any macro quoting, you could just use:
8 %chk (result = Intensity (%) ) val=Intensity (%) NOTE: The data set WORK.ONE has 1 observations and 1 variables.
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 save with the early bird rate—just $795!
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.