DATA Step, Macro, Functions and more

Converting to month macro getting just January....

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Converting to month macro getting just January....

Hi,

I'm not sure why this is not giving me the right date.  I'm trying to create a macro from to pull 'February' as the "rolling_month", but "rolling_month" comes out at January (even when I change the -11 to something else, like 13 or 5.

data date;

date="1FEB2013"d;  *This is the date of run (regarding data up until month before date of run);

date_end=intnx("month", date, -1, "end");

rolling_month=put((month(intnx("month", date_end, -11, "begin"))), $monname.);

rolling_month_end=put((intnx("month", date_end, -11, "sameday")), $yymmn6.);

format date date_end date9.;

run;

proc print data=date;

run;

Any help would be appreciated!!  Thanks in advance.


Accepted Solutions
Solution
‎03-20-2013 08:43 AM
Frequent Contributor
Posts: 97

Re: Converting to month macro getting just January....

hi,

Delte extra ....'month' in the following  line and check/...

rolling_month=put((intnx("month", date_end, 1, "end")), $monname.);


This gives....rolling_month ........February...


Regards


ALLU

data date;

date="1FEB2013"d;  *This is the date of run (regarding data up until month before date of run);

date_end=intnx("month", date, -1, "end");

rolling_month=put((intnx("month", date_end, 1, "end")), $monname.);

rolling_month_end=put((intnx("month", date_end, -11, "sameday")), $yymmn6.);

format date date_end date9.;

run;

proc print data=date;

run;

View solution in original post


All Replies
Solution
‎03-20-2013 08:43 AM
Frequent Contributor
Posts: 97

Re: Converting to month macro getting just January....

hi,

Delte extra ....'month' in the following  line and check/...

rolling_month=put((intnx("month", date_end, 1, "end")), $monname.);


This gives....rolling_month ........February...


Regards


ALLU

data date;

date="1FEB2013"d;  *This is the date of run (regarding data up until month before date of run);

date_end=intnx("month", date, -1, "end");

rolling_month=put((intnx("month", date_end, 1, "end")), $monname.);

rolling_month_end=put((intnx("month", date_end, -11, "sameday")), $yymmn6.);

format date date_end date9.;

run;

proc print data=date;

run;

New Contributor
Posts: 4

Re: Converting to month macro getting just January....

It worked!!  Thanks allurai!

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 254 views
  • 0 likes
  • 2 in conversation