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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.