Autorecode and hierarchical ID variables

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

sda030
Posts: 1
Joined: Tue Jul 29, 2014 3:52 pm

Autorecode and hierarchical ID variables

Postby sda030 » Tue Jul 29, 2014 4:15 pm

Hi!
Using Stata 22 and confident with syntax. However, when I try to use the autorecode function for my ID variables, I get different results from without. In short, my TIMSS dataset has very long ID for students, teachers, classes, schools and countries (to accommodate unique IDs across many waves). Other software I will have to use have a limit on the variable lengths.

AUTORECODE IDCNTRY /INTO CNTRYID.
*The following four lines ensure that the original variables which are only unique per country, become unique in the dataset. Must execute these before the autorecode.
COMPUTE IDSCHOOL2=CNTRYID*10000+IDSCHOOL.
COMPUTE IDCLASS2=CNTRYID*1000000+IDCLASS.
COMPUTE IDTEACH2=CNTRYID*100000000+IDTEALIN.
COMPUTE IDSTUD2= CNTRYID*100000000+IDSTUD.
EXECUTE.
AUTORECODE IDSCHOOL2 /INTO SCHOOLID.
AUTORECODE IDCLASS2 /INTO CLASSID.
AUTORECODE IDSTUD2 /INTO STUDLID.
When I use the two sets of ID variables (IDXXX2 vs. XXXID) in multilevel software (Stata, Mplus and MLwiN) I get an error saying that variables having been created based on a particular set (e.g. average socioeconomic status in IDCLASS2) is not the same as CLASSID. My supervisor says may logic is fine, so I have no idea. I can't even find any descripencies when I inspect random sections of the dataset. Ideas?
RubenGeert
Posts: 100
Joined: Mon May 19, 2014 6:06 am

Re: Autorecode and hierarchical ID variables

Postby RubenGeert » Tue Jul 29, 2014 7:32 pm

I kinda see what you're trying to do but I don't see what's going wrong. What do you mean by "different results from without"? How different?

Kind regards,

Ruben Geert van den Berg
www.spss-tutorials.com

Who is online

Users browsing this forum: No registered users and 1 guest

cron