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 (February 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 27 Feb 2008 15:06:56 -0500
Reply-To:   Hari Nath <hari_s_nath@YAHOO.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Hari Nath <hari_s_nath@YAHOO.COM>
Subject:   Re: weights in tabulate
Comments:   To: Yu Zhang <zhangyu05@GMAIL.COM>

Thanks Yu for your answer.....gave me a good start....i could not find much info from documentation......okay from your answer, usage of var statement is needed as the requested analysis variables are sum and mean....two ways i could think of, but dont know which one is right....hope to get some help....

*******method 1 with var and weight statement; proc tabulate data = one missing ; class popu type mos ; var anal1 ; weight weighted_anal1 ; ********weighted_anal1 = wgt * anal1; tables popu * type , mos*anal1 *(sumwgt = 'Sum' mean = 'Mean') ; title4 "Weighted tabulate run for population*type*mos" ; run ;

********method 2 with var but no weight statement; proc tabulate data = one missing ; class popu type mos ; var weighted_anal1 ; ********weighted_anal1 = wgt * anal1; tables popu * type , mos*weighted_anal1 *(sumwgt = 'Sum' mean = 'Mean') ; title4 "Weighted tabulate run for population*type*mos" ; run ;

many thanks hari.

On Wed, 27 Feb 2008 12:48:16 -0600, Yu Zhang <zhangyu05@GMAIL.COM> wrote:

>Hi, Hari, > >You may try to create a new variable in your report dataset, say >weighted_anal1=wgt*anal1. >then in proc tabulate, > > proc tabulate data = one missing ; > class popu type mos ; > weight wgt ; > tables popu * type , mos*(sumwgt = 'Sum' mean = 'Mean') ; > title4 "Weighted tabulate run for population*type*mos" ; >run ; > >I didn't test it with mock data. But the online doc says: > SUMWGT > >is the sum of the weights, Wi, computed as: sigma Wi. > >HTH > >Yu > > > >On Wed, Feb 27, 2008 at 11:17 AM, Hari Nath <hari_s_nath@yahoo.com> wrote: > >> Hi all, >> >> Normally i use weights for counts and most of time in proc summary....but >> now i need some help in figuring out to weight the sum and means in proc >> tabulate.....the 'wgt' variable is the weight and it is an integer created >> based on 'type' variable....can someone correct me with the right way of >> weighting here.......i looked at the archives and one example had to >> multiply the weight variable somthing like >> tables (popu*type)*wgt*sumwgt, mos*anal1 *(sum = 'Sum' mean = 'Mean') ; >> >> which doesnt work for me....... >> >> many thanks >> hari. >> >> ********my code; >> proc tabulate data = one missing ; >> class popu type mos ; >> var anal1 ; >> weight wgt ; >> tables popu * type , mos*anal1 *(sum = 'Sum' mean = 'Mean') ; >> title4 "Weighted tabulate run for population*type*mos" ; >> run ; >>


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