LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 6 Sep 2008 12:25:16 -0700
Reply-To:     hua gang <hg448@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         hua gang <hg448@YAHOO.COM>
Subject:      Re: convert date format
Comments: To: Daniel Nordlund <djnordlund@VERIZON.NET>
Content-Type: text/plain; charset=iso-8859-1

Sorry for not including complete program, so I sent again.

Thanks for reply, Dan.

I used the following to compute the difference between yearsly dates, only my first date variable, "date_base" has different format like, 03JUN08. Because of it, the computation didn't work. Once I got ride of date_base," and datedif0 it worked perfectly. So, this is the reason for me to try to convert "date_base", but I can't find a way to do it right away.

Thanks again for your help.

Hua

arraydc{4} date_base dateyear_1 dateyear_2 date_year3; arraydd{4} daydif0 daydif1 daydif2 datedif3;

seth4; doi=2to4; last_date=.; j=i; dd{i}=.; dountil((last_date ne .) or (dc{i} = .)); j=j-1; ifdc{j} ne .thenlast_date=j; elseifj=1thenleave; end;

/* only need to do a diff here since SAS dates count days from a set point */ ifnmiss(last_date,dc{i})=0thendd{i}=dc{i}-dc{last_date}; end;

dropi j; *last_date;

run;

----- Original Message ---- From: Daniel Nordlund <djnordlund@VERIZON.NET> To: SAS-L@LISTSERV.UGA.EDU Sent: Saturday, September 6, 2008 1:56:51 PM Subject: Re: convert date format

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of hua > gang > Sent: Saturday, September 06, 2008 10:48 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: convert date format > > Thanks for comment. Not for display purpose, I wanted to convert all dates in the > same format for computational purpose. > In my current data set, some dates are in one format, and others are in different > format. > > Hua >

But that was Jack's point. If you are using SAS dates (and if you aren't, you should), it doesn't matter if they are formatted differently, no conversion is necessary. The only exception would be if you both SAS dates and SAS datetimes. In that case you will need to convert the datetimes to dates (or dates to datetimes), and for that you would use the datepart() function (or dhms() function).

Hope this is helpful,

Dan

Daniel Nordlund Bothell, WA USA

>


Back to: Top of message | Previous page | Main SAS-L page