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 (December 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 26 Dec 2001 09:53:11 -0800
Reply-To:   amy <amywang11790@YAHOO.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   amy <amywang11790@YAHOO.COM>
Subject:   less efficient code ?
Content-Type:   text/plain; charset=ISO-8859-1

Hello,all, I am trying to do following tasks: club_member,mth by month, get percentage which is sum(mth)/count(distinct member_id); 2.get percentage of total sum(mth)/count(distinct member_id)as perc_mth for example: month members mth perc_mth Oct2001 10 1 10% Nov2001 20 10 50% Feb2002 30 3 10% Apr2002 40 4 10% Total 100 18 18%

I did following less efficient code for huge datasets. It took me hours to get results. Any input for improve efficiency is greatly appreciated. Best wishes for the new year. Amy.

data temp2; set temp1; mth=0; if ( some condition...........) then mth=1; expiry_month1=trim(put(put(expiry_month, YYMMn6. ), $6.)); run;

proc sql; create table temp1 as select expiry_month1 ,count(distinct member_id) as num ,sum(mth) as mth ,sum(mth)/count(distinct member_id)as perc_mth from temp2 group by expiry_month1; quit;

proc sql; create table temp3 as select 'Total' as expiry_month1 ,count(distinct member_id) as num ,sum(mth) as mth ,sum(mth)/count(distinct member_id)as perc_mth from temp2 quit;

data final; set temp1 temp3; run;

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