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 (January 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 18 Jan 2010 06:45:10 -0500
Reply-To:     SAS user <sasuser4@GOOGLEMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SAS user <sasuser4@GOOGLEMAIL.COM>
Subject:      Re: Creating a new dataset-beg/end dates
Content-Type: text/plain; charset=ISO-8859-1

Thanks to everyone for the replies. I have used Daniel's code and works perfectly. Thanks a lot Daniel.

On Sun, 17 Jan 2010 22:24:38 +0100, =?ISO-8859-1?Q?Daniel_Fern=E1ndez?= <fdezdan@GMAIL.COM> wrote:

>well, I was thinking perhaps you prefer to have a id list by each >year. Imagine you want to see who were between 1955 to 2010: > >%let initial_year=y1955; >%let end_year=y2010; > >data idlist_by_year; >set have; >array yr(*) &initial_year - &end_year; >do z=1 to dim(yr); >if year(beg)<= z + substr("&initial_year",2,4)-1 <=year(end) then yr(z) =id; >end; >drop z beg end id; >run; > > >I hope it is helpful. > >Dani Fernandez >Barcelona > >El d�a 17 de enero de 2010 22:10, Daniel Fern�ndez <fdezdan@gmail.com> escribi�: >> hi, >> >> I think this is what you want: >> >> data have; >> informat Beg yymmdd8.; >> informat End yymmdd8.; >> format Beg date9.; >> format End date9.; >> input ID Beg End; >> cards; >> 10007 19570301 19840718 >> 10008 19570301 20070214 >> 10009 19580604 19760630 >> 10020 19570301 20081231 >> ; >> >> data yearlist_by_id; >> set have; >> do year=year(beg) to year(end); >> retain id; >> output; >> end; >> drop beg end; >> run; >> >> Daniel Fernandez. >> Barcelona. >> >> >> 2010/1/17 SAS user <sasuser4@googlemail.com>: >>> I want to create a list with IDs and for which years these IDs are >>> available (based on beg and end date). In particular, I want to have a >>> list of the years for which these IDs are available (1992, 1993... 2000 >>> etc) rather than a range (1992-2000) as I want at the end to have the >>> following output >>> >>> id >>> 10020 1991 >>> 10020 1992 >>> 10020 1993 >>> 10020 1994 >>> etc >>> for each id. >>> >>> On Sun, 17 Jan 2010 11:44:35 -0600, Joe Matise <snoopy369@GMAIL.COM> wrote: >>> >>>>What are you planning on doing ultimately? Are you trying to get score or >>>>something by year [ie, 'what is the score for observations that contain >>> 1981 >>>>in their year range']? More than likely the way to answer your question >>>>will be answering your ultimate purpose, and not the question you've >>> asked, >>>>as I don't imagine the question you've asked is the right one. >>>>- >>>>Joe >>>> >>>>On Sun, Jan 17, 2010 at 11:06 AM, SAS user <sasuser4@googlemail.com> >>> wrote: >>>> >>>>> Thank you for the reply. >>>>> >>>>> What I want to do is to be able to create a list of observations for >>> each >>>>> year based on beg and end dates. So for example for id 10020 I want to >>>>> have an indicator/variable to designate that this observation is >>> included >>>>> in an index in 1957, 1958....and 2008. I 'm looking for the most >>> efficient >>>>> way to accomplish this considering that each observation is likely to be >>>>> in an index for many years and at the end I would like to have a list of >>>>> observations included in the index for each year. >>>>> >>>>> >>>>> >>>>> >>>>> On Sun, 17 Jan 2010 11:24:45 -0500, Arthur Tabachneck >>>>> <art297@NETSCAPE.NET> wrote: >>>>> >>>>> >In order to answer your question the list probably needs more >>> information >>>>> >about what you are trying to do. If it is simply to select based on >>> Beg >>>>> >and End, you might already have the variables you need. E.g.: >>>>> > >>>>> >data have; >>>>> > informat Beg yymmdd8.; >>>>> > informat End yymmdd8.; >>>>> > format Beg date9.; >>>>> > format End date9.; >>>>> > input ID Beg End; >>>>> > cards; >>>>> >10007 19570301 19840718 >>>>> >10008 19570301 20070214 >>>>> >10009 19580604 19760630 >>>>> >10020 19570301 20081231 >>>>> >; >>>>> > >>>>> >data want; >>>>> > set have (where=(Beg<='01MAR1957'd<=End)); >>>>> >run; >>>>> > >>>>> >HTH, >>>>> >Art >>>>> >-------- >>>>> >On Sun, 17 Jan 2010 08:28:47 -0500, SAS user <sasuser4@GOOGLEMAIL.COM> >>>>> >wrote: >>>>> > >>>>> >>Hello >>>>> >> >>>>> >>Below is a sample of my data >>>>> >> >>>>> >>ID Beg End >>>>> >>10007 19570301 19840718 >>>>> >>10008 19570301 20070214 >>>>> >>10009 19580604 19760630 >>>>> >>10020 19570301 20081231 >>>>> >> >>>>> >>The objective is to create a dataset which will allow me to identify >>> the >>>>> >>IDs which were included in the dataset as identified by the end >>> variable. >>>>> >> >>>>> >>For example for ID 10020 I want to have a variable that will enable >>> me to >>>>> >>identify that this ID was in the dataset in 1957, 1958, 1959.... till >>>>> >>12/2008. >>>>> >> >>>>> >>Any suggestions would be most welcome. >>>>> >> >>>>> >>Thanks! >>>>> >>> >>


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