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.
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: