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?
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.
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: