Hello Stata Community.
I'm working in my master thesis with a data base about middle class, their values and political perceptions for 24 Latin American countries. I'll focus on 2012, 2014 and 2016 waves. So, my explained variable is a categorical one (0=lower classe ; 1=middle class and 2=upper class). To run the model I have created this variable for each country and year. The problem is that i have to "isolate" the middle class in one variable, and that's relatively easy by hand with "gen" command, but I think there is an easier way than doing it one by one (or not). So, i want to run a loop which take every categorical income variable and split it in 3 different variables (LW_10_90_2012=lower classe ; MC_10_90_2012=middle class and UC_10_90_2012=upper class as an example). Here the list of variables for 2012 (there're the same variables for 2014 and 2016). Is it possible to do this process by using a loop or is it better to do it one by one?
Thank you so much!!!
per_10_90_Total_q10g_12
per_10_90_Mexico_q10g_12
per_10_90_Guatemala_q10g_12
per_10_90_Salvador_q10g_12
per_10_90_Honduras_q10g_12
per_10_90_Nicaragua_q10g_12
per_10_90_CostaRica_q10g_12
per_10_90_Panama_q10g_12
per_10_90_Colombia_q10g_12
per_10_90_Ecuador_q10g_12
per_10_90_Bolivia_q10g_12
per_10_90_Peru_q10g_12
per_10_90_Paraguay_q10g_12
per_10_90_Chile_q10g_12
per_10_90_Uruguay_q10g_12
per_10_90_Brasil_q10g_12
per_10_90_Venezuela_q10g_12
per_10_90_Argentina_q10g_12
per_10_90_RD_q10g_12
per_10_90_Haiti_q10g_12
per_10_90_Jamaica_q10g_12
per_10_90_Guyana_q10g_12
per_10_90_TriniT_q10g_12
per_10_90_Belice_q10g_12
per_10_90_Surinam_q10g_12
Related Posts with Problems with a loop to generate new variables
What are the results of reldist in Stata?When relative distribution method is used to compare the distribution similarity of two samples, rel…
Using loops to generate dummy for placebo regressionsHi In my dataset I have yearly variable, from 1995 to 2006 and a treatment happening in year 2003. I…
BSWEIGHTS without stratum in the dataI am wanting to use bsweights to resample the weights before a bootstrap a weighted regression. I do…
What are the results of the Kolmogorov-Smirnov test in Stata?The following figure is the Kolmogorov-Smirnov test (KS test) I conducted in Stata using ksmirnov co…
Help needed for using data frames to extract dataHi, I am using Stata 16 and would need help in the extraction of data. I intend to use data frames …
Subscribe to:
Post Comments (Atom)
0 Response to Problems with a loop to generate new variables
Post a Comment