Date: Mon, 19 Jul 2010 10:27:01 -0700
Reply-To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject: Re: date cleaning/conversion
In-Reply-To: <635592.64937.qm@web25602.mail.ukl.yahoo.com>
Content-Type: text/plain; charset=utf-8
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Franz
> Sent: Monday, July 19, 2010 10:05 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: date cleaning/conversion
>
> Dear All,
>
> How do I convert d1 into date9. format?
>
> data dummy;
> input d1 $15.;
> cards;
> 02/jan/75
> 04.feb.2007
> 14-mars.71
> 15/mars.2005
> 12-dec-2008
> 18.apr.70
> ;
>
>
> Thanks & Kind regards,
> Franz
My first suggestion is to have whoever is producing this mess clean it up. If that is not possible then you can use the ANYDTDTE format.
data want;
set dummy;
sasdate = input(d1,anydtdte.);
format sasdate date9.;
run;
But first, you will need to make sure the months are the appropriate 3-letter designation: 14-mars.71 needs to be 14-mar.71 I won't try to give an example of that since I don't know what other problems might exist in the data. Best to clean it up at the source.
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
|