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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

%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;

View solution in original post

2 REPLIES 2
DBailey
Lapis Lazuli | Level 10

%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;

SASguyCO
Calcite | Level 5

Works like a charm!  Thanks so much for the quick reply.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3204 views
  • 0 likes
  • 2 in conversation