Page 1 of 1

Creating a level 2 variable from level 1 data

Posted: Tue Mar 26, 2013 11:44 pm
by drbris0769
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

Re: Creating a level 2 variable from level 1 data

Posted: Wed Mar 27, 2013 11:07 am
by ChrisCharlton
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):

Code: Select all

CALC c100="ethnicity"==1
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:

Code: Select all

MLCOunt "neighbourhood" c101
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:

Code: Select all

MLSum "neighbourhood" c100 c102
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:

Code: Select all

CALC c103 = (c102/c101) * 100
c103 should now contain the level 2 variable that you want and can be renamed to something appropriate.