BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasphd
Lapis Lazuli | Level 10

 

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16
We can use the date literals as below 


data output; set datarolling_ETFS; if rankdate<'30Jun2005'd then delete; run;

Thanks,
Jag

View solution in original post

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16
We can use the date literals as below 


data output; set datarolling_ETFS; if rankdate<'30Jun2005'd then delete; run;

Thanks,
Jag
novinosrin
Tourmaline | Level 20

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

Astounding
PROC Star

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.

Kurt_Bremser
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1754 views
  • 3 likes
  • 5 in conversation