I have often wanted to use sampling weights to generate tables of mean values for a variable. The tabulate command does not let one use sampling weights (pweight), and my solution which follows looks long-winded. Is there a better method? I use the mean command iteratively, and then copy the values by hand onto the table I want.
Code:
local agedesc: value label agecat local gendesc: value label male local urbandesc: value label urban foreach a in 0 1 2 3 4 5 { local label: label `agedesc' `a' display " " display " " display " ---------------------------------------------------------- " display " Age category: `label' " display " ---------------------------------------------------------- " foreach g in 0 1 { local label: label `gendesc' `g' display " " display " ---------------- Gender: `label' ----------------" foreach u in 0 1 { local label: label `urbandesc' `u' display " " display "`label'" mean pscomp if agecat==`a' & male==`g' & urban==`u' [pweight=swgt] } } }
Comment