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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 542 views
  • 0 likes
  • 2 in conversation