LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (February 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 3 Feb 2009 15:05:06 -0500
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: array label question
Comments: To: Hari Nath <hari_s_nath@YAHOO.COM>

Hari,

In that case, couldn't you just use a rename statement? R=e.g.,:

data need (rename=( all1=_2007_1_1_1 all2=_2007_1_1_2 all3=_2007_1_2_1 all4=_2007_1_2_2 all5=_2007_1_3_1 all6=_2007_1_3_2 all7=_2007_2_1_1 all8=_2007_2_1_2 all9=_2007_2_2_1 all10=_2007_2_2_2 all11=_2007_2_3_1 all12=_2007_2_3_2 all13=_2007_3_1_1 all14=_2007_3_1_2 all15=_2007_3_2_1 all16=_2007_3_2_2 all17=_2007_3_3_1 all18=_2007_3_3_2 all19=_2007_4_1_1 all20=_2007_4_1_2 all21=_2007_4_2_1 all22=_2007_4_2_2 all23=_2007_4_3_1 all24=_2007_4_3_2 all25=_2008_1_1_1 all26=_2008_1_1_2 all27=_2008_1_2_1 all28=_2008_1_2_2 all29=_2008_1_3_1 all30=_2008_1_3_2 all31=_2008_2_1_1 all32=_2008_2_1_2 all33=_2008_2_2_1 all34=_2008_2_2_2 all35=_2008_2_3_1 all36=_2008_2_3_2 all37=_2008_3_1_1 all38=_2008_3_1_2 all39=_2008_3_2_1 all40=_2008_3_2_2 all41=_2008_3_3_1 all42=_2008_3_3_2 all43=_2008_4_1_1 all44=_2008_4_1_2 all45=_2008_4_2_1 all46=_2008_4_2_2 all47=_2008_4_3_1 all48=_2008_4_3_2 )) ; array all {2007 : 2008,1 : 4,1 : 3,1 : 2} ;

do i = 1 by 1 until (last.indiv_id) ; set have ; by indiv_id ;

all{yr,qtr,channel_cd,incentive_type} = contacts ; end ; run ;

Art --------- On Tue, 3 Feb 2009 14:45:36 -0500, Hari Nath <hari_s_nath@YAHOO.COM> wrote:

>Hi Art, > >Thanks for your reply. Yes i do have the identical code from your proc >tranpose, but the problem being it takes 30 minutes using an array, but an >hour and a half using a transpose for ~200 million record with ><10variables. > >On Tue, 3 Feb 2009 14:37:24 -0500, Arthur Tabachneck <art297@NETSCAPE.NET> >wrote: > >>Hari, >> >>Are you just trying to accomplish something like the following?: >> >>data have ; >> input Obs INDIV_ID yr qtr channel_Cd >> Incentive_Type CONTACTS ; >> labl=catx('_',yr,qtr,channel_Cd,Incentive_Type); >> cards ; >> 1 100000100004 2007 1 1 2 1 >> 2 100000100004 2007 1 3 2 7 >> 3 100000100004 2008 3 1 2 1 >> 4 100000100005 2007 1 1 2 1 >> 5 100000100005 2007 1 3 2 7 >> 6 100000100005 2008 2 3 >>2 >> 1 >> 7 100000100005 2008 3 3 1 1 >> 8 100000100005 2008 3 3 2 2 >> 9 100000100007 2007 4 1 2 2 >> 10 100000100007 2008 3 1 2 4 >>; >> >>proc transpose data=have out=want; >> by INDIV_ID; >> id labl; >> idlabel labl; >> var contacts; >>run; >> >>Art >>------- >>On Tue, 3 Feb 2009 13:45:37 -0500, Hari Nath <hari_s_nath@YAHOO.COM> >wrote: >> >>>Hi all, >>> >>> >>>Following code gives the desired output except the labels i want to. for >>>example after transposing the data, for the first record with contacts = >1 >>>its a combination of yr = 2007, qtr = 1, channel = 1 and incentive = 2. >So >>>i would label the variable for the corresponding first record as >>>2007_1_1_2 and so on. I could get this using proc transpose, but its >>>taking a long time compared to array as the data is few hundred millions. >>>Anybody have an idea how can i achieve this using the following array >>>method. >>> >>>thanks in advance..... >>> >>>data have ; >>> input Obs INDIV_ID yr qtr channel_Cd Incentive_Type CONTACTS ; >>>cards ; >>> 1 100000100004 2007 1 1 2 1 >>> 2 100000100004 2007 1 3 2 7 >>> 3 100000100004 2008 3 1 2 1 >>> 4 100000100005 2007 1 1 2 1 >>> 5 100000100005 2007 1 3 2 7 >>> 6 100000100005 2008 2 3 2 1 >>> 7 100000100005 2008 3 3 1 1 >>> 8 100000100005 2008 3 3 2 2 >>> 9 100000100007 2007 4 1 2 2 >>> 10 100000100007 2008 3 1 2 4 >>>; >>>run ; >>> >>>data need ; >>> array all {2007 : 2008,1 : 4,1 : 3,1 : 2} ; >>> >>> do i = 1 by 1 until (last.indiv_id) ; >>> set have ; >>> by indiv_id ; >>> >>> all{yr,qtr,channel_cd,incentive_type} = contacts ; >>> end ; >>>run ;


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