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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 2179 views
  • 0 likes
  • 3 in conversation