Hi, any reason why I can use the Date (format YYMMP7.) in a range? for example I want to select records that fall within if Date => 2001.01 and Date <= 2011.11
Thanks
I got it.. if Date => "01Jan2001"d and Date <= "01Nov2011"d;
Shorthand that uses the equality operators but no need for AND:
if "01Jan2001"d <= Date <= "01Nov2011"d;
You could also use WHERE and BETWEEN (it really means between + the two dates) ...
where date between "01Jan2001"d and "01Nov2011"d;
this also works ...
where date between "01Nov2011"d and "01Jan2001"d ;
I got it.. if Date => "01Jan2001"d and Date <= "01Nov2011"d;
Shorthand that uses the equality operators but no need for AND:
if "01Jan2001"d <= Date <= "01Nov2011"d;
You could also use WHERE and BETWEEN (it really means between + the two dates) ...
where date between "01Jan2001"d and "01Nov2011"d;
this also works ...
where date between "01Nov2011"d and "01Jan2001"d ;
hi ... if you are using a SAS data set, you could also use WHERE and BETWEEN (it really means between + the two dates) ...
where date between "01Jan2001"d and "01Nov2011"d;
this also works ...
where date between "01Nov2011"d and "01Jan2001"d ;
Hi -
Just to confirm your understanding:
In SAS, every date is a unique number on a number line. Dates before January 1, 1960, are negative numbers; those after January 1, 1960, are positive.
To write a SAS date constant (in IF or WHERE statements for example), enclose a date in quotation marks in the standard SAS form ddMMMyyyy and immediately follow the final quotation mark with the letter D.
The D suffix tells SAS to convert the calendar date to a SAS date value. Of course you could also use the unformatted numeric value instead.
Example:
data want;
set sashelp.air(where=(date=0)) sashelp.air(where=(date="01JAN1960"d));
run;
Thanks Udo, I remembered after I posted it.. but thought there was a different approach with different formats.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.