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

i want to write a comment to the log and i want to use an apostrophe in my comment.

below is a sample code illuminating the issue.

the first %put statement using double quotes as a work around but the comment in the log will have the double quotes and this maybe undesirable. the second %put statement fails and causes problems going forward in the code for the third %put statement because it is interpreted a using single quotes and thus is expecting a closing single quote.  is there a way to use an apostrophe in this situation and have it be ignored as a single quotes string initiator?

 

code sample:

%let x=5;
%let date_today=&sysdate;
%put "today's date is: &date_today and &sysdate.";
%put today's date is: &date_today and &sysdate.;
%put my number x is: &x.;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Use macro quoting. Such as %bquote() which allows unbalanced quotes.

422  %put %bquote(today's date is: %sysfunc(today(),date9.).);
today's date is: 03OCT2022.

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Use macro quoting. Such as %bquote() which allows unbalanced quotes.

422  %put %bquote(today's date is: %sysfunc(today(),date9.).);
today's date is: 03OCT2022.

 

deboershapes
Calcite | Level 5

Thanks it worked.  It had a side effect of breaking the code coloring scheme (in sas studio).  To work around that I added an apostrophe commented out directly after it like this

 

%let date_today=&sysdate;
%put %bquote(today's date is &date_today and &sysdate..);*';

before:

 

sas text coloring issue.pngafter:

sas text coloring issue work around.png

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 581 views
  • 1 like
  • 2 in conversation