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 (June 2001, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 11 Jun 2001 10:03:17 -0400
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: DATE QUESTION

Moreover, depending on just how the summary of the data is to be prepared and used, there may not even be a need to create a new variable. Instead, just apply the format(yymms7.) to the existing variable. For example:

proc summary data=... ... format filldate yymms7.; ... run;

On Mon, 11 Jun 2001 08:44:17 -0400, Eileen Farrelly <Eileen_Farrelly@PCIT.COM> wrote:

>Gregg, >Thank you... the SAS format yymms7. worked the best - it kept everything in >chronological order. > >Eileen > >Thanks to all who responded! > > > > > > >"Gregg P. Snell" <gsnell@DATASAVANTCONSULTING.COM>@LISTSERV.UGA.EDU> on >06/11/2001 08:35:59 AM > >Please respond to "Gregg P. Snell" <gsnell@datasavantconsulting.com> > >Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> > > >To: SAS-L@LISTSERV.UGA.EDU >cc: >Subject: Re: DATE QUESTION > > >Eileen, > >The spaces are the result of a default numeric-to-character conversion when >creating date_SVC. Retaining the logic you have, a LEFT function will >remove the spaces: > > DOSM=MONTH(FILLDATE); > DBYR=YEAR(FILLDATE); > date_SVC=LEFT(TRIM(DBYR))||"/"||LEFT(TRIM(DOSM)); > >Better still, simply use a date format that matches exactly what you want: > > date_SVC=put(filldate,yymms7.); > >HTH... > >Gregg P. Snell >Data Savant Consulting >(913) 638-4640 >(208) 977-1943 fax >http://www.datasavantconsulting.com > >Co-chair of MWSUG 2001 >http://www.mwsug.org/mw_2001/index.htm > > > >Eileen Farrelly <Eileen_Farrelly@PCIT.COM> wrote in message >news:OF97B5FB8C.033B8549-ON85256A68.0041A72B@pcit.com... >> This is a simple problem... I want to take a SAS data (in the format of >> mmddyy10.) and create a new variable with the year and month only to get >a >> summary of the dates covered in the dataset by year and month. >> >> I have dates like: >> >> 12/20/2000 >> 01/31/2001 >> 03/26/2001 >> 04/10/2001 >> 05/03/2000 >> 06/26/2000 >> >> and used this code that actually worked at splitting up the month and >year >but I would like to get rid of the spaces >> it creates between year and month. >> >> DOSM=MONTH(FILLDATE); >> DBYR=YEAR(FILLDATE); >> date_SVC=TRIM(DBYR)||"/"||(DOSM); >> >> But my output looks like: >> >> 2000/ 12 >> 2001/ 1 >> 2001/ 3 >> 2001/ 4 >> 2000/ 5 >> 2000/ 6 >> >> >> And I would like: >> >> 2000/12 >> 2001/1 (or 2001/01) >> 2001/3 >> etc... >> >> Thanks in advance, >> Eileen Farrelly >> >> >>


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