×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)

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.

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

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?

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

you know other (and better) SAS forums? let me know!!!

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

(OP)
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

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

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 "alignment" 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 http://www.sas.com/service/techsup/intro.html

or take a look at the SAS OnlineDoc:
http://v8doc.sas.com
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

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

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

1.  Go to http://ftp.sas.com/techsup/download/base/
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close