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 (September 2011, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 30 Sep 2011 12:14:52 -0400
Reply-To:     Tom Abernathy <tom.abernathy@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Tom Abernathy <tom.abernathy@GMAIL.COM>
Subject:      Re: Summing Array Elements

I have used strings to handle this type of continuous enrollment problem.

estring=cats(of flg(*));

do i=12 to dim(flg); twm(i) = substr(estring,i-11,12) = repeat('1',12-1); end;

On Fri, 30 Sep 2011 12:06:45 -0400, Jack Clark <jclark@HILLTOP.UMBC.EDU> wrote:

>All, > > > >I have a person-level data set which has 36 flags (1/0) representing >monthly enrollment in a program. Starting with the 12th month and going >through the 36th month, I want to set another set of flags (1/0) >indicating whether the person was continuously enrolled during the >current and 11 previous months (total of 12 months enrollment). > > > >I have coded a possible solution below. My question is whether there is >a shorthand expression or array syntax to refer to 12 consecutive array >elements based on the position of 1 array element? Is there a way to >replace the 12 items in my SUM function with a shorter reference to >these variables? > > > > > >*FLG array is enrollment flags > >*TWM array is what I am trying to set when current month and 11 prior >months are = 1. > > > >data medexp (drop=i); > > merge medexp_09 medexp_10 medexp_11; > > by recipno; > >array flg (36) jul09me aug09me sep09me oct09me nov09me dec09me > > jan09me feb09me mar09me apr09me may09me jun09me > > jul10me aug10me sep10me oct10me nov10me dec10me > > jan10me feb10me mar10me apr10me may10me jun10me > > jul11me aug11me sep11me oct11me nov11me dec11me > > jan11me feb11me mar11me apr11me may11me jun11me; > >array twm (36) jul08 aug08 sep08 oct08 nov08 dec08 > > jan09 feb09 mar09 apr09 may09 jun09 > > jul09 aug09 sep09 oct09 nov09 dec09 > > jan10 feb10 mar10 apr10 may10 jun10 > > jul10 aug10 sep10 oct10 nov10 dec10 > > jan11 feb11 mar11 apr11 may11 jun11; > >* for each month june-2009 through june-2011 ; > >* check if person was in medicaid expansion during all 12 of the past 12 >months ; > >do i = 12 to 36; > > if sum(flg(i),flg(i-1),flg(i-2),flg(i-3),flg(i-4),flg(i-5), > > flg(i-6),flg(i-7),flg(i-8),flg(i-9),flg(i-10),flg(i-11)) = 12 >then twm(i) = 1; > > else twm(i) = 0; > >end; > >run; > > > >(I know the array names in FLG and TWM do not exactly match up in terms >of the Year values - it is because the FLG variables are using fiscal >year and the TWN variables are being converted to a naming convention >using calendar year). > > > >Thanks. > > > > >Jack > > > >Jack Clark >Senior Programmer >phone: 410-455-6256 >fax: 410-455-6850 >jclark@hilltop.umbc.edu > >University of Maryland, Baltimore County >Sondheim Hall, 3rd Floor >1000 Hilltop Circle >Baltimore, MD 21250 > >Please consider the environment before printing this e-mail and/or any attachments. > > >Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.


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