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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.