Date: Thu, 20 Oct 2011 13:22:51 -0500
Reply-To: Yu Zhang <zhangyu05@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Yu Zhang <zhangyu05@GMAIL.COM>
Subject: Re: Fun With Dates
Content-Type: text/plain; charset=ISO-8859-1
regarding your first question, you can roll your own date format like
proc format ;
picture userfmt (default=11)
low-high='%d %b %Y' (datatype=date) ;
put today userfmt.;
before you apply it to your data, you will have to check to make sure it is
a valid date. the one in your example with UNK in the variable, certainly
will be invalid.
Compress function can be used to remove the spaces.
On Thu, Oct 20, 2011 at 1:09 PM, Mary Rosenbloom <
> Hi all,
> I have some variables formatted as SAS dates (date9 format), such as:
> Then I have character string, EVTDT, which has this form:
> 25 DEC 2011
> I have been asked to make all of the "dates" look alike in format. I'm
> pretty sure that we need to keep the EVTDT variable as a character string,
> since it can sometimes contain a partial date, such as:
> UNK DEC 2011
> (1) Is there a date format like DATE9 but with spaces between the day and
> month, month and year?
> (2) Is there a SAS function that can remove the spaces like this:
> 25 DEC 2011 -> 25DEC2011
> I have found that it is sometimes hard to search for a function when you
> don't know it's name, only what it does.
> Thanks so much for your help!
> Mary R.