Hello,

I am doing my best to follow all the statalist guidelines. My apologies if I am still lacking in etiquette.

I am using Public Use Micro Data from IPUMS USA. These data come from the American Community Survey conducted by the US Census Bureau. IPUMS provides a level of geography called a PUMA (Public Use Microdata Area) that can contain one or more counties. The data contain observations at the individual level, and I want to create variables that summarize these individual characteristics into PUMA-level characteristics.


Below is an example of the data I am using.
Variables are:
smigpuma0 (the level of geography for which I want to summarize individual-level characteristics),
age (each individual's age), and
perwt (the person weight variable).

If I want to create a variable called pum_age which is the mean age of individuals for each smigpuma0 (or PUMA), I run the following code:
Code:
bysort smigpuma0: egen pum_age = mean(age)
This works nicely, but this command will not accept a weight. I tried:

Code:
bysort smigpuma0: egen pum_age = mean(age) [fweight=perwt]
But Stata returns the following message: "weights not allowed".

Is there another way to accomplish what I am trying to do? I use Stata 13 SE.

Example data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long smigpuma0 byte age int perwt
4702100 0  5
4804600 0 19
2901800 0 17
 101900 0 36
3200400 0 17
1303700 0 65
3702690 0 16
2900100 0  8
 101900 0 11
5159300 0 13
4806700 0 64
3100200 0  8
2601000 0 31
4100300 0 15
1000300 0  3
3904000 0 31
 101100 0 11
2601000 0 44
1601190 0 12
3604000 0 31
end
label values age age_lbl
label def age_lbl 0 "Less than 1 year old", modify