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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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