05-23-2016 12:23 PM
I am trying to extract variables from a dataset by certain date, but my code is not working. I will get the columns header with 0 rows.
can someone please help? attached is the code I use.
CREATE TABLE TEST AS
SELECT CURRENT_DATE, BLANK_NUMBER
WHERE CURRENT_DATE IN (04-01-2016 - 04-30-2016);
05-23-2016 01:27 PM
You should have gotten error messages with that code. In the future if you have code throwing errors include the log with the code and the error messages for best results.
If your current_date is an actual SAS date value then you do comparisons with literal values using "ddMONYYYY"D syntax. That is the only allowable form for explicit dates. So you likely needed to use "01APR2016"d and "30APR2016"d. Second the IN operator doesn't use a - to indicate a range, use : instead in( 1:10) is range of 1 to 10.
Easier in this case may be to use
Where Month(Current_date) = 4
where Current_date is between "01APR2016"d and "30APR2016"d;