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

HAVE:

/* in yyyy-mm-dd format */

/* date1 is a macro variable within the program */

 

/* current value of date1 */

date1 = 2017-04-20

 

NEED: 

date1 = '2017-04-20'

 

ATTEMPT:

/* Tried to put double quotes around it then replace it with single quotes, but this didn't work. */

data _null_;
set date1;
date1= quote(date1);
%put &date1
date1= %sysfunc (translate (&date1,%str(%"),%str(%')));

run;

 

Can someone tell me the place where I'm going wrong? 

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
Astounding
PROC Star
%let date1 = %unquote(%str(%'&date1%'));

 

Reeza
Super User
How are you generating that macro variable? That's where you make the change, so is it via SQL, data step?
unwanted_banana
Calcite | Level 5

It comes from a refined table (getdates) which only has one data value in its column (date1)

 

proc sql noprint;
select date
into :date1
from getdates;
quit;

Reeza
Super User
proc sql noprint;
select quote(date, "'") 
into :date1
from getdates;
quit;

Pass it with quotes in the value already then.


@unwanted_banana wrote:

It comes from a refined table (getdates) which only has one data value in its column (date1)

 

proc sql noprint;
select date
into :date1
from getdates;
quit;


 

Ksharp
Super User
%let date1=2017-04-20 ;
%let date2 = %bquote('&date1');

%put &date2. ;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 2800 views
  • 2 likes
  • 4 in conversation