All-
Due to the way our database is set up, I need to pull a weeks worth of data at a time in the format 'YYYY-MM-DD' and it has to be enclosed in single quotes. I've never been really good at the whole reading or not reading those strange characters with macro variables so I thought I'd ask the experts! I'm fairly certain this is an easy solution.
Here is what I have so far. This gives me the two macro date variables &date1 and &date2. However, I need to have single 'quotes' around them so that it resolves to '2013-01-28' and '2013-02-03' respectively. I know I can't just put single quotes '&date1' and '&date2' like such but I'm not sure how to go about this. Your input is always really appreciated!
%let datem=today();
data _null_;
date1=put(intnx('week.2',&datem,-1,'b'),yymmddd10.);
date2=put(intnx('week.2',&datem,-1,'e'),yymmddd10.);
call symputx('date1',date1);
call symputx('date2',date2);
run;
%put &date1 &date2;
%let datem=today();
data _null_;
date1=put(intnx('week.2',&datem,-1,'b'),yymmddd10.);
date2=put(intnx('week.2',&datem,-1,'e'),yymmddd10.);
call symputx('date1',"'"||date1||"'");
call symputx('date2',"'"||date2||"'");
run;
%put &date1 &date2;
%let datem=today();
data _null_;
date1=put(intnx('week.2',&datem,-1,'b'),yymmddd10.);
date2=put(intnx('week.2',&datem,-1,'e'),yymmddd10.);
call symputx('date1',"'"||date1||"'");
call symputx('date2',"'"||date2||"'");
run;
%put &date1 &date2;
Works like a charm! Thanks so much for the quick reply.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.