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

within testit macro i want macro variables to be resolved and the outfile name to be generated as sasuser05AUG11_Test's

one way to force the resolution is to use %unquote , %unquote works if the oname does not contain the single quote

Any suggestions to make it work with oname having single quote or any other quoted character as well ?

%macro testit(outputlocation, outputname);

%let outfile=&outputlocation/&outputname;

%put &outfile;

%mend;

%let _metauser=sasuser;

%let oname=%str(&)_metauser.%str(&)SYSDATE._Test%str(%')s;

%put This is how values are passed into the stored process: &oname;

%let oloc=c:\mysas;

%testit(&oloc, &oname); 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

Are you coding for full job security?

BQUOTE will quote an unmatched un-escaped single quote.

I usually macro variables in %PUT.

%macrotestit (outputlocation, outputname);

   %letoutfile =&outputlocation/&outputname;

   %put& outfile;

   %mend;

%let_ metauser=sasuser;

%letoname =% str(&)_ metauser.%str(&) SYSDATE._Test% str(%') s;

%letoname =% nrbquote(%unquote(& oname));

%put This is how values are passed into the stored process: % superQ( oname);

%letoloc=c:\mysas;

%testit(&oloc, &oname); 

I would change the date format to YYYYMMDD so the filenames will sort in a more pleasing order.

%let oname=%str(&)_metauser.%sysfunc(today(),yymmddn8.)_Test%str(%')s;

View solution in original post

1 REPLY 1
data_null__
Jade | Level 19

Are you coding for full job security?

BQUOTE will quote an unmatched un-escaped single quote.

I usually macro variables in %PUT.

%macrotestit (outputlocation, outputname);

   %letoutfile =&outputlocation/&outputname;

   %put& outfile;

   %mend;

%let_ metauser=sasuser;

%letoname =% str(&)_ metauser.%str(&) SYSDATE._Test% str(%') s;

%letoname =% nrbquote(%unquote(& oname));

%put This is how values are passed into the stored process: % superQ( oname);

%letoloc=c:\mysas;

%testit(&oloc, &oname); 

I would change the date format to YYYYMMDD so the filenames will sort in a more pleasing order.

%let oname=%str(&)_metauser.%sysfunc(today(),yymmddn8.)_Test%str(%')s;

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
  • 1 reply
  • 704 views
  • 1 like
  • 2 in conversation