BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
David_Billa
Rhodochrosite | Level 12

In the below code, I want the macro variable REPORTINGDATE to resolve as 31MAR2007. So I would like to know what value to be passed as Input for the variable x.

 

 

data _null_;
x=input(put(&reportingdate,$8.),yymmdd8.);
format x date9.;
call symput('REPORTINGDATE',x);
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User
%let reportingdate=20070331;

data _null_;
x = input("&reportingdate",yymmdd8.);
call symput('reportingdate',put(x,date9.));
run;

Note that in most cases, you won't need a formatted date in the macro variable. For calculations and comparisons, the raw value is easier to handle.

And if you want the date displayed, use a better format like e8601da10. (equal to yymmddd10.).

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

What is the initial value of &Reportingdate?

David_Billa
Rhodochrosite | Level 12
It is coming from batch process.

So you can assign any value
Kurt_Bremser
Super User
%let reportingdate=20070331;

data _null_;
x = input("&reportingdate",yymmdd8.);
call symput('reportingdate',put(x,date9.));
run;

Note that in most cases, you won't need a formatted date in the macro variable. For calculations and comparisons, the raw value is easier to handle.

And if you want the date displayed, use a better format like e8601da10. (equal to yymmddd10.).

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 555 views
  • 1 like
  • 3 in conversation