Say I have a variable 'ReadTime' with the format datetime22.3, how to add the where statement to get the subset.
say I have
data want;
set exist;
where readtime>'01DEC2018:00:40:00.000';
run;
Then sas reports 'WHERE clause operator requires compatible variables'. Any idea? Thanks.
will this work?
data want;
set exist;
where readtime>'01DEC2018:00:40:00.000'dt
run;
will this work?
data want;
set exist;
where readtime>'01DEC2018:00:40:00.000'dt
run;
@liyongkai800 wrote:
Though I've no idea why simply add 'dt then it works lol, it works indeed. Thanks.
See here:
Look at the manual on the topic named literals. It is system for passing in character data in a specific format, which SAS can convert on the fly. So a suffix of:
'ddmmmyyyy'd = date in form ddmmmyyyy dt = date time as given in the example '...'n = named literal of a column from third party software such as Excel where name may not be SAS conformant.
Thank you @liyongkai800
Hi,
I am trying to compare a datetime variable using the following expression
where eff_dt>'01DEC2018:00:00:00.000'dt
but it is throwing me an error
I tried
where eff_dt > today( )
but this didn't work either.
Format of eff_dt is DateTime22.3 and values are like 31DEC2199:00:00:00.000
What am I doing wrong here ?
Thanks
Varun
ok, If your eff_dt is a datetime variable i.e the internal value is stored in seconds and you want to compare with today() an integer date, You would need to extract the the integer date from the datetime value using datepart
For example
if datepart(eff_dt)>today() ;/*assuming your eff_dt is a datetime value*/
if both are date values, i.e the internal value is stored as integers as the number of days from jan1,1960 you could use
if eff_dt>today() /*both being date values with integers*/
HTH & Regards!
This worked !
You are a life saver. Thanks a ton.
Varun
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.