Help using Base SAS procedures

Duration Question

Not applicable
Posts: 0

Duration Question

Hello All,
I am trying to get a report of all the obs for the week ending a week before today. For eg. if today is 5/19/10. I would like to get all the observations for the week of 5/5/10 - 5/12/10. I am running a DI job to do this, but I am not sure on how to specify the date ranges. Can anyone offer any suggestions.

Thank You

Trusted Advisor
Posts: 2,124

Re: Duration Question

Posted in reply to deleted_user

I'm not a DI user. But the appropriate selection in an IF statement from the data step would look something like

IF today()-14 LE obsdate LE today()-7 THEN ...

or a SQL WHERE expression of
obsdate BETWEEN today()-14 AND today()-7

I suspect that DI would use one of those two approaches. Message was edited by: Doc@Duke
Super User
Posts: 5,876

Re: Duration Question

You use SAS Extract transform in DI Studio, or potentiality SQL Join if more than one table is involved.

If your data is huge, or reside in an external RDBMS, consider to calculate the start and end dates of the BETWEEN interval in a pre-process. Store them as macro variables, for use in the Extract.
The use of functions and calculation can prevent SAS from using indexes, or to send the code to the RDBMS for execution.

Data never sleeps
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation