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

Hi,

I have a statement end date that I need to figure the statement start date, which is exactly the same day but in the month previous.

for example

id bill_end_date bill_st_date

1 12Jan2011 12Dec2010

2 23Feb2011 23Jan2011

etc.

thanks for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Something like this may get your started:

data have;

infile cards;

format bill_end_date date9.

       bill_st_date date9.;

input id bill_end_date : date9.;

bill_st_date=intnx('mon', bill_end_date,-1,'sameday');

cards;

1 12Jan2011

2 23Feb2011

;

proc print;run;

Kindly Regards,

Haikuo

View solution in original post

4 REPLIES 4
Reeza
Super User

intnx function with the same option.

Check the docs.

Haikuo
Onyx | Level 15

Something like this may get your started:

data have;

infile cards;

format bill_end_date date9.

       bill_st_date date9.;

input id bill_end_date : date9.;

bill_st_date=intnx('mon', bill_end_date,-1,'sameday');

cards;

1 12Jan2011

2 23Feb2011

;

proc print;run;

Kindly Regards,

Haikuo

Danglytics
Calcite | Level 5

thank you for your help.

what happens to months with 31 days? I assume it goes to month end?

Haikuo
Onyx | Level 15

Bingo! It will go to the last day of the month. Try it for yourself, change 12Jan2011 to 31Mar2011, and see what happens.

Regards,

Haikuo

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1065 views
  • 0 likes
  • 3 in conversation