Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating the age of a file eg to show all files > 6 months 2

Status
Not open for further replies.

BrianAustin1949

Programmer
Sep 25, 2001
5
GB

Hi

Using a DTTM field, I need to check for dates that are greater than 6 months old.

today ( ) – 6 months.

Any help will be very welcome.

Regards.

Brian.
 
I do not know what you are referring to by DTTM, but to check 6 months old from a field, say first order date 'od1_dt', you could do following:
INTCK('MONTH',od1_dt,today())
Similarly, you could do
INTCK('WEEK',od1_dt,today())
INTCK('YEAR',od1_dt,today())

Also check out the sibling function INTNX in your SAS documentation.

I feel like there is not enough subscriber to the SAS forum, compared to others. Could we let more people know about TEK-TIPS?
 
Thanx Cruel.

I looked at INTNK and then moved on to use INTCK to count the age of the file in days from th current day.

Actual_Days=intck('DTDAY',CURRENT,ACTUAL_START_DTTM);
DAYS_DIFF = (current - Actual_Days);


thanks again for your help.

Brian
 
Not to beat a dead horse, but I'd stay away from INTCK and INTNX because both use the beginning of the interval specified (unless this is what you want).

INTNX('interval',start-from,increment<,'alignment'>)

For example, if today's date were March 31, 2002, then INTNX('MONTH',today(),-6) would come up with the SAS Date equivalent of October 1, 2001, when you really may want October 31, 2001. There is the optional &quot;alignment&quot; option which you can specify to use the beginning, middle, or end of the MONTH (in this case). This doesn't usually get the calculation to the day, though.

To be more accurate (comparing by the same day of the month), use the following:

if date > mdy(day(today()),month(today())-6,year(today()));

This will subset your data for dates that are within the last six months. Keep in mind that the YOUNGER SAS Date is a HIGHER value.

I know this seems like a rediculously long way to get a SAS Date from six months ago, but it is more accurate to the calendar day.

And yes, you can search SAS' technical support website at
or take a look at the SAS OnlineDoc:
Click on the sod_register.html to register (don't worry, they won't spam you...they just want your email so that they know if anybody is really using it)
Log in by clicking on the sashtml link.

Good luck,
ucandoit
 
Here's a macro from SAS Institute that should do the trick for you:

1. Go to 2. Download:
macroexporternew.sas to export multiple SAS Data Sets to multiple Excel spreadsheets or multiple MS Access files.
macroexporterexisting.sas to update multiple Excel spreadsheets from multiple SAS Data Sets.
macroimporter6a.sas to import multiple Excel spreadsheets or multiple MS Access files into multiple SAS Data Sets.
3. Check out macro and change where necessary.
4. Submit and enjoy!

Good luck,
ucandoit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top