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 (October 2011, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: Mary Rosenbloom <mary.rosenbloom.sas@gmail.com>
In-Reply-To:  <201110201809.p9KGZVAC003474@waikiki.cc.uga.edu>
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) ; run;

data _null_; today=today(); put today userfmt.; run;

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.

HTH

Yu

On Thu, Oct 20, 2011 at 1:09 PM, Mary Rosenbloom < mary.rosenbloom.sas@gmail.com> wrote:

> Hi all, > > I have some variables formatted as SAS dates (date9 format), such as: > > IMPDT > AWAREDT > > 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 > > Questions: > (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! > > Cheers, > Mary R. >


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