Hi,
Please can someone help me with the code to find the months difference between the current month (i.e. it would be August 2020, but would reflect the current month whenever the code was run) and the "RUN_DATE" variable (which is Numeric and has a DATE9. format)?
An example of records for RUN_DATE is 31MAY2012.
So it would be :
Months_difference = month(today's date) - month(RUN_DATE)
So for the 31MAY2012 example, Months_difference would equal 99 (August 2020 - May 2012).
SAS provides a few functions to deal with date and time intervals, namely INTNX (calculates a target from a start and a difference value) and INTCK (calculates a difference between two date or time values).
So you should try this:
Months_difference = intck('month',run_date,today());
Study the documentation about the method modifier.
SAS provides a few functions to deal with date and time intervals, namely INTNX (calculates a target from a start and a difference value) and INTCK (calculates a difference between two date or time values).
So you should try this:
Months_difference = intck('month',run_date,today());
Study the documentation about the method modifier.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.