BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
twelch
Calcite | Level 5

Hello,
I have read into SAS a Netezza table where one of the columns is a date ( The column type was date ) . 
Now I am trying to create several sub-tables in SAS, but I'm having trouble comparing dates in SAS.

Code to create first SAS dataset

proc sql;
   connect to netezza
   (server=xxxx database=xxxx  PORT = xxxx user=xxxx password="&mysaspasswd"
connection=global);
create table SASDATA.WEEKLY_REPORT_RT_LOAD as
select * from connection to netezza
   (select a.* from WEEKLY_REPORT_RT_LOAD a  order by 1,2);
run;

code for subtable

%let starttime = today() - 30;

proc sql;
create table sasdata.rtload_tab_1 as
select * from SASDATA.WEEKLY_REPORT_RT_LOAD

where marketdate >= &starttime;
run;

below is the picture of the column (variable) marketdate that i am trying to filter on.

Untitled.png

While the table is created. The data has not been filtered by the date as i would have thought.

As a matter of fact it is not being filtered at all.
Any help would be appreciated.

Thanks,
Tom

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

From the displayed values of MARKETDATE it is a DATETIME variable and the STARTTIME you created is a DATE variable.

I would try modifying the sql to

where datepart(marketdate) ge &starttime;

View solution in original post

2 REPLIES 2
ballardw
Super User

From the displayed values of MARKETDATE it is a DATETIME variable and the STARTTIME you created is a DATE variable.

I would try modifying the sql to

where datepart(marketdate) ge &starttime;

twelch
Calcite | Level 5

Thanks. That worked like a charm. Smiley Happy

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 2092 views
  • 0 likes
  • 2 in conversation