BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
abhinayingole
Obsidian | Level 7


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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

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.
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

View solution in original post

2 REPLIES 2
Quentin
Super User

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.
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Quentin
Super User

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.
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 635 views
  • 2 likes
  • 2 in conversation