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 (July 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 21 Jul 2006 12:43:08 -0700
Reply-To:     BK <byronkirby@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         BK <byronkirby@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: Dates - count
Comments: To: sas-l@uga.edu
In-Reply-To:  <1153502873.584383.137350@m79g2000cwm.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"

the function YRDIF should work well for you, it counts year doundries... try this: Byron

data test; do y=2006 to 1985 by -1; do m=1 to 12; OldDate=MDY(m,1,y); CurrentDate=today(); output; end; end; run;

proc sql; select distinct( case when floor(YRDIF(OldDate,CurrentDate,'ACT/ACT')) < 10 then INT(YRDIF(OldDate,CurrentDate,'ACT/ACT')) else 10 end) as years, count(*) from test group by case when floor(YRDIF(OldDate,CurrentDate,'ACT/ACT')) < 10 then INT(YRDIF(OldDate,CurrentDate,'ACT/ACT')) else 10 end; quit; run;

> > NickyNN wrote: > > Would you like a count of the number of years from today's date ? > > > > How about something like this: > > > > proc format ; > > value RangeFmt (multilabel) > > 0="0 Year Old" > > 1-high="1 Year Old" > > 2-high="2 Year Old" > > 3-high="3 Year Old" > > 5-high="5 Year Old" > > 10-high="10 Year Old"; > > run; > > > > data TestData; > > input CharDate $ ; > > > > SASDate = input(CharDate,yymmdd8.); > > Today=today() ; > > YearsOld=year(Today)-year(SASDate) ; > > > > format SASDate Today Date7.; > > cards; > > 20051111 > > 20041016 > > 20030102 > > 19990518 > > 19990610 > > 20001231 > > 20010101 > > 20010317 > > 20011224 > > 19800101 > > 19800102 > > ; > > run; > > > > proc sort data=TestData ; > > by descending SASDate ; > > run ; > > > > proc summary data=Testdata nway ; > > class YearsOld / mlf order=Data; > > Var SASDate ; > > format YearsOld RangeFmt. ; > > output out=DateCounts (drop=_type_ _freq_) n=DateCounts; > > run ; > > > > proc print data=SummaryCounts ; > > run; > > > > Cheers, > > Nicky.


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