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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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