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.

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 915 views
  • 2 likes
  • 2 in conversation