DATA Step, Macro, Functions and more

create date as mmdd numeric

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 91
Accepted Solution

create date as mmdd numeric

am trying to create a macro variable to append to a report name and I need it to be mmdd, (ie 0709, for july 9th).  So far I have been unsuccessful trying to separate the date parts and concatenating back together in this format.  I know there is probably an easy fix but I am just not getting there.  Any assistance will be greatly appreciated.

 

Thanks.


Accepted Solutions
Solution
‎12-07-2017 10:39 AM
PROC Star
Posts: 1,190

Re: create date as mmdd numeric

Use mmddyyN4 format like this

 

data _null_;
work_date= today();
call symput ("wod",put(work_date,mmddyyN4.));
run;

%put &wod.;

View solution in original post


All Replies
PROC Star
Posts: 1,190

Re: create date as mmdd numeric

How are your date values stored?

Super User
Super User
Posts: 9,211

Re: create date as mmdd numeric

Show some test data, we can't guess!

data _null_;
  call symput('d',put('01JAN2016'd,yymmdd10.));
run;

ods rtf file="abc_&d..rtf";
...

For example.

Frequent Contributor
Posts: 91

Re: create date as mmdd numeric

sorry,

 

I am using the today function for the date.

 

data _null_;

work_date= today();

call symput ("wod",put(work_date,yymmddn8.));

run;

Solution
‎12-07-2017 10:39 AM
PROC Star
Posts: 1,190

Re: create date as mmdd numeric

Use mmddyyN4 format like this

 

data _null_;
work_date= today();
call symput ("wod",put(work_date,mmddyyN4.));
run;

%put &wod.;
Frequent Contributor
Posts: 91

Re: create date as mmdd numeric

Thank you so much, you all are awesome!
Contributor
Posts: 56

Re: create date as mmdd numeric

 

data month_date;
x='07jun1989'd;
format x mmddyyn4.;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 155 views
  • 3 likes
  • 4 in conversation