DATA Step, Macro, Functions and more

Restricting data by Date proc sql;

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Restricting data by Date proc sql;

Hello,

I am trying to reduce the data returned from a very large table by the date (Proc sql in SAS 9.4)

The format of the column is DDYYMM8. (Number)

 

In my where clause I have tried:

where date >= 01-01-16

where date >= 01/01/16

and the reverse eg 16/01/01 etc

 

All attempts so far have resulted in dates still being returned which are older than 01/01/16

Can anyone help please?


Accepted Solutions
Solution
‎11-23-2016 03:05 PM
Respected Advisor
Posts: 3,124

Re: Restricting data by Date proc sql;

try this:

 

where date LE '01jan2016'd

All of the SAS date stored as numbers, counting days from 1/1/1960. So you either use the number of days directly, in this case, 20454 days from 1/1/1960, or tell SAS how to read it correctly, such as in the above example.

 

View solution in original post


All Replies
Solution
‎11-23-2016 03:05 PM
Respected Advisor
Posts: 3,124

Re: Restricting data by Date proc sql;

try this:

 

where date LE '01jan2016'd

All of the SAS date stored as numbers, counting days from 1/1/1960. So you either use the number of days directly, in this case, 20454 days from 1/1/1960, or tell SAS how to read it correctly, such as in the above example.

 

New Contributor
Posts: 2

Re: Restricting data by Date proc sql;

Thank you for this it's worked perfectly!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 148 views
  • 1 like
  • 2 in conversation