I have a date variable that I am trying to report on for a specific range.
However, I am having issues tring to get the formatting of the code right.
The date format is as follows - DDMONYEAR:00:00:00.000000
I have tried the following code -
data Quotes;
set test.client
(where= ('15SEP2015:18:00:00.000000'd <= p_created_date <= '25SEP2015:18:00:00.000000'd)
keep= p_created_date
run;
Thank you for any and all help 🙂
Joshua
Looks like a DATETIME value, use DT instead of D for the literal.
Looks like a DATETIME value, use DT instead of D for the literal.
This is a datetime variable according to the format. Does your data have time stamps associated with the dates? Or are all the values of the time part of p_created_date equal to 00:00:00? The where statement is saying that you want any p_created_date between Sept 15, 2015 at 6:00 PM through Sept 25, 2015 at 6:00 PM. If you are trying to limit it with the 6:00 PM and are having issues (which I would suggest posting what the issues are), I would try eliminating the ".000000" from your datetime ranges and modifying d to dt at the end. If you are not intending to limit it with the 6:00 PM, I would suggest either changing the 18 to 00 and adding dt instead of d at the end, or just using the datepart() function of p_created_date and removing everything after the 2015 in your limits.
You have to remain consistent with date or datepart.
data have;
range1 = '15SEP2015:18:00:00.000000'dt;
range2 = '25SEP2015:18:00:00.000000'dt;
p_create = '20SEP2015:18:00:00.000000'dt;
format range1 range2 p_create datetime25.;
run;
data want;
set have;
if range1 < p_create < range2 then yes = 'yes';
if datepart(range1) < '20sep2015'd < datepart(range2) then check = 'yes';
run;
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.