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.

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