Wednesday, 20 July 2011

Date Evaluation

Filtering the date in your data using the today() function in SAS is great, as it will provide you with all the data with today's date.

However filtering for a certain number of days from today's date (e.g. 50 days) using the today() function (e.g. today()-50) can take a while to run, which is not great if your manager needs the data on their desk by the hour and you want to keep your job!!

Using the %eval function can speed up the process:


%let date= %eval(%sysfunc(today())- 50);


The code above creates the macro 'date' using the %eval function to calculate the value of the system function today()-50.

Now all you need to do is filter the date in your data set greater than &date and you'll have all the data you need in no time!

If you don't believe me try using the time it function to test the difference! http://superbasssas.blogspot.com/2011/07/time-it.html

No comments:

Post a Comment