%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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.