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
Opal | Level 21

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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