Hi - I have a data table that contains a field that represents number of months and a datetime field.
I'm attempting to subtract the 'Months' field from the 'LastDate' field to create the 'NewDateNeeded'.
Any assistance appreciated!!
Since your "dates" are actually what SAS considers to be date/time values, you need to use a date/time interval in INTCK.
In a SAS data step, use
newdateneeded = intck('dtmonth',lastdate,-2,'s'); format newdateneeded datetime18.;
P.S. I forgot to mention that my table has well over 5K rows, typing in the month to subtract individually is not an option. I've tried the field name instead without success. Please Help!!
The way your initial post reads very strongly implies that your existing data set has a months variable to apply to the given Lastdate value. If that is not the case then where have you provided information on why month is wanted? No where.
What "field name"???? You haven't shown anything like a "field name" that would hold anything related to a number of months.
So show us an example of your actual data set. Don't add or remove anything. Then using that example of the data walk us through description of how we are supposed to know that Lastdate needs to be shifted by 2 months, 1 month or 16 months. Whatever is needed.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.