BookmarkSubscribeRSS Feed
jflo36
Calcite | Level 5

Hi 

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.

 

PROC SQL;
CREATE TABLE TEST AS
SELECT CURRENT_DATE, BLANK_NUMBER
FROM BLANK.DATA
WHERE CURRENT_DATE IN (04-01-2016 - 04-30-2016);
QUIT;

 

Thanks,

 

3 REPLIES 3
ballardw
Super User

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

or

where Current_date is between "01APR2016"d and "30APR2016"d;

jflo36
Calcite | Level 5

Thanks ballardw! I try it but it did not work.

ballardw
Super User

Please show the Log of the submitted code and any error messages. "Didn't work" is awful vague to try to work with.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1002 views
  • 0 likes
  • 2 in conversation