Hi there,
I am currently looking at a 2-level dataset of individuals nested in neighbourhoods.
I have information on each individual's ethnicity as a categorical level 1 predictor (Asian, Black, White), but would like to aggregate this information on each individual, to the neighbourhood level, to obtain the percentage of individual's for a particular neighbourhood that are white for example - thus forming a level 2 variable.
Is there any advice on how to go about this?
Kind Regards
Creating a level 2 variable from level 1 data
-
- Posts: 1
- Joined: Tue Mar 26, 2013 11:27 pm
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: Creating a level 2 variable from level 1 data
There may be better ways to do this, but here is one way that I believe you can achieve what you want (This assumes c100 to c103 are free in your worksheet, if not then substitute columns that are):
1) Create a zero/one variable indicating whether the record has the required characteristic. This can be done via the Data Manipulation->Calculate window or via a command (substituting the 1 for the category code that you're interested in):
2) Calculate the total number of units within each level 2 variable. This can be done via the Data Manipulation->Multilevel Data Manipulations window or via a command:
3) Calculate the number of units matching the category you are interested in. This can again be done via Data Manipulation->Multilevel Data Manipulations or the command:
4) Use the results of the two calculations above to work out the average within each level 2 variable. This can be done via Data Manipulation->Calculate or the command:
c103 should now contain the level 2 variable that you want and can be renamed to something appropriate.
1) Create a zero/one variable indicating whether the record has the required characteristic. This can be done via the Data Manipulation->Calculate window or via a command (substituting the 1 for the category code that you're interested in):
Code: Select all
CALC c100="ethnicity"==1
Code: Select all
MLCOunt "neighbourhood" c101
Code: Select all
MLSum "neighbourhood" c100 c102
Code: Select all
CALC c103 = (c102/c101) * 100