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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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