data output;
set datarolling_ETFS;
if rankdate < '20050630'YYMMDDN8. then delete;
run;
I have problem to define the format date
Edit by KB: Formatted code and put it in correct window.
We can use the date literals as below
data output;
set datarolling_ETFS;
if rankdate<'30Jun2005'd then delete;
run;
We can use the date literals as below
data output;
set datarolling_ETFS;
if rankdate<'30Jun2005'd then delete;
run;
Assuming your date is a numeric sas date formatted with yymmddn8
if rankdate<'30JUN2005'd then delete;
should work
However, you need to confirm whether or not your date is numeric or char
Proc contents should give you that information
The answer depends on what your variable actually contains.
It is a true SAS date? Then use:
if rankdate < '30Jun2005'd then delete;
Is it a six-digit number? Then use:
if rankdate < 20050630 then delete;
Is it a character variable of some sort? Then use:
if input(rankdate, 6.) < 20050630 then delete;
But you need to understand some basic information about what is in your variable to select the proper answer.
To keep the ymd date format, use the input() function:
data output;
set datarolling_ETFS;
if rankdate < input('20050630',YYMMDD8.) then delete;
run;
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 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.
Ready to level-up your skills? Choose your own adventure.