BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

I've created the macro variable and it resolves as follows.

 

SYMBOLGEN:  Macro variable REPORTING_DATE resolves to 30JUN2018
reporting_date           = 30JUN2018

Since the macro variable 'reporting_date' is character, I need to convert it to numeric to do comparison with other date variable.

 

Could someone please guide me?

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

It can be done several ways, but most direct from what you have is:

%let reporting_date=30JUN2018;

data want;
  set have;
  where date <= "&reporting_date."d;
run;

You will note here that the text from the macro variable gets put into the quotes, which have a d after - which means for SAS to treat that text as a date literal.  You could also say:

data want;
  set have;
  where date <= input("&reporting_date.",date9.);
run;

Which may be useful if you have formats of date other then date9. - as only date9 works with date literals.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 798 views
  • 0 likes
  • 2 in conversation