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;
HI Reeza,
this is the original date:
where (DateCreated = '14jul2016:00:00:000'dt);
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.
HI Reeza,
this is the original date:
where (DateCreated = '14jul2016:00:00:000'dt);
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()
Please mark @Reeza's answer as accepted.
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.
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.