Help using Base SAS procedures

Formatting a date question

Accepted Solution Solved
Reply
Contributor
Posts: 36
Accepted Solution

Formatting a date question

I'm having problems reading the date on my sas table

id                  date

111              01sept10 000000

the date is september 1 2010

ive tried to read this date and produce results like this:

id                  date                         expiry

111              01sept10 000000         yes

by using a code like this

length expiry $ 10

if date < '21Apr2014' d then expiry ='yes'; , the problem is the code does not appear to recognize this date format and give incorrect results. I was thinking that the solution may be  to change the format of the date to something like 01/09/2010 as this format has worked for me in the past. How do i change the code or which is the quickest way?

Thanks.


Accepted Solutions
Solution
‎10-01-2014 03:23 PM
Super User
Posts: 19,770

Re: Formatting a date question

If you're dealing with an actual SAS dataset post the proc contents on it.

proc contents data=have; run;

My guess is its a date time variable so you'll need to use the date part function for the comparison:

if datepart(date) < '21Apr2014' d then expiry ='yes';

View solution in original post


All Replies
Solution
‎10-01-2014 03:23 PM
Super User
Posts: 19,770

Re: Formatting a date question

If you're dealing with an actual SAS dataset post the proc contents on it.

proc contents data=have; run;

My guess is its a date time variable so you'll need to use the date part function for the comparison:

if datepart(date) < '21Apr2014' d then expiry ='yes';

Contributor
Posts: 36

Re: Formatting a date question

Thanks this works

Contributor
Posts: 36

Re: Formatting a date question

thanks that works

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 202 views
  • 0 likes
  • 2 in conversation