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

Hi Guys, I'm new to SAS (EG 9.3) and very new here...please be gentle and use simple words!

 

I have inherited some code that is ran each morning, with the date manually changed each day.  I want to automate this code, so i am trying to change the manual date to today(), so it doesn’t need any user input.

 

if i take the where...Today() statement out, i get all the dates, when i put it back in i don’t  get any observations.

 

Thanks in advance for nay help given,

 

paul

 

proc sql;
create table work.alerts_daily as
   select
       intID,
       datecreated,
      description,
      subject,
      SubjectEntity,
      CustomerNumber
   from table.alert
      where description like 'Alert1' or description like 'Alert2' or description like 'Alert3';
quit;


proc sql;

   create table LN_Alert_DAY as
      select distinct a. *,
      b. Property

   from work.alerts_daily as

      a inner join work.customer_status2 as b

      on a. CustomerNumber = b. ID

      order by intID;

run;

 

proc sql;
   create table work.LN_Alert_DT as
      select * from LN_Alert_DAY
         where Datecreated = today();
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
pandhandj
Obsidian | Level 7

HI Reeza,

 

this is the original date:

 

where (DateCreated = '14jul2016:00:00:000'dt);

View solution in original post

5 REPLIES 5
Reeza
Super User

What did your manual date look like?

 

Most likely the variable datecreated isn't a SAS date which is what you're expecting. It could either be a character variable or a date time variable. Check the variable type and format for the DateCreated variable. 

pandhandj
Obsidian | Level 7

HI Reeza,

 

this is the original date:

 

where (DateCreated = '14jul2016:00:00:000'dt);

Reeza
Super User

That's a date time variable, not a date variable. 

 

You can use the following instead of just today() to create a date time variable.

 

 

DateCreated = dhms(today(), 0, 0,0) 

 

Or you could use datepart function to change dateCreated to a date variable. 

 

Datepart(dateCreated)= today()

pandhandj
Obsidian | Level 7
Woo! and Hoo!

thats got it going,

thanks very much Reeza.
PGStats
Opal | Level 21

Please mark @Reeza's answer as accepted.

PG

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
  • 5 replies
  • 1202 views
  • 0 likes
  • 3 in conversation