BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ken_oy
Fluorite | Level 6

Hi, everyone,

I try to use "call symput" do the following step,

I want to do:

data test;

call symput("test_name", "Kid's First Test");

run;

%put &test1;

but I don't think in my code the "call symput" can deal with a string with a " ' ".

Any help? thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

Hi,


Actually, CALL SYMPUT doesn't mind the unmatched single quote (since it is inside double quotes).  But it cause problems for the %PUT statement.

If you wrote

  %put Kid's First Test ;

That apostrophe would look to SAS like an unmatched single quote, and cause problems.

When &test_name resolves to that value, the single quote causes the same problems.

To avoid the problems, you mask the apostrophe by using macro quoting functions.

For example:

  %put %bquote(&test_name)  ;

or

  %put %superq(test_name) ;

HTH,

--Q.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

2 REPLIES 2
Quentin
Super User

Hi,


Actually, CALL SYMPUT doesn't mind the unmatched single quote (since it is inside double quotes).  But it cause problems for the %PUT statement.

If you wrote

  %put Kid's First Test ;

That apostrophe would look to SAS like an unmatched single quote, and cause problems.

When &test_name resolves to that value, the single quote causes the same problems.

To avoid the problems, you mask the apostrophe by using macro quoting functions.

For example:

  %put %bquote(&test_name)  ;

or

  %put %superq(test_name) ;

HTH,

--Q.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
data_null__
Jade | Level 19

When the text is resolved you need to be sure that text does not cause errors.  Typically that is done with quoting functions %SUPERQ %BQUOTE etc.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 2773 views
  • 0 likes
  • 3 in conversation