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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 2571 views
  • 0 likes
  • 2 in conversation