BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zetter
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

3 REPLIES 3
Reeza
Super User

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';

zetter
Calcite | Level 5

Thanks this works

zetter
Calcite | Level 5

thanks that works

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 759 views
  • 0 likes
  • 2 in conversation