Hi all,
I am working on a dataset with 37 variables and 380 observations. Individuals from three non-randomized groups were given 0, 1 or 2 interventions.
Each individual was surveyed twice, once after the intervention, and once again two years later. During the second survey the same individuals were contacted and identified as the same with a unique caseid and a TimeSeries variable (0 if first survey, 1 if second). The second survey only repeated 4 questions from the first survey (the dependent measures) and collected demographic information including gender, age, education, occupation.
The data is inputted currently as follows in the long format. (REdithSS REdithWealth and Age are completely filled for all observations TimeSeries == 1).
The team I am with wants to make a new dependent variable that is the measure of the change for nQ19 between time 0 and time 1 and then run a multiple linear regression with Village (intervention received) and demographics as the predictors.
From what I understand this would require reshaping to wide format. However, when I try reshape this is what I get:
The Stata output seems to suggest that I would have to manually copy the responses from time 1 to time 0 for the same caseid to make the variables constant (the research team has already decided that they consider demographics to be consistent over the two year period).
Is there any other way to conduct this regression? If not, is there code that would allow me to copy responses over from time 1 to time 0 for the same caseid?
Thank you for your help,
Christopher Tracey
I am working on a dataset with 37 variables and 380 observations. Individuals from three non-randomized groups were given 0, 1 or 2 interventions.
Each individual was surveyed twice, once after the intervention, and once again two years later. During the second survey the same individuals were contacted and identified as the same with a unique caseid and a TimeSeries variable (0 if first survey, 1 if second). The second survey only repeated 4 questions from the first survey (the dependent measures) and collected demographic information including gender, age, education, occupation.
The data is inputted currently as follows in the long format. (REdithSS REdithWealth and Age are completely filled for all observations TimeSeries == 1).
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long Village float nQ19 long(REdithSS REdithWealth) int Age float TimeSeries 2 1 . . . 0 1 3 . . . 0 1 2 . . . 0 3 3 . . . 0 1 1 . . . 0 2 1 . . . 0 3 1 . . . 0 1 2 . . . 0 2 2 . . . 0 2 2 . . . 0 1 2 . . . 0 2 3 . . . 0 3 4 . . . 0 1 1 . . . 0 1 4 . . . 0 end label values Village village label def village 1 "Bugembe", modify label def village 2 "Kijinjomi", modify label def village 3 "Kyakabuzi", modify label values REdithSS LEdithSS label values REdithWealth LEdithWealth
From what I understand this would require reshaping to wide format. However, when I try reshape this is what I get:
Code:
reshape wide nQ19 nQ20 nQ21 nQ22, i(caseid) j(TimeSeries) (note: j = 0 1) variable Age not constant within caseid variable gender not constant within caseid variable Rtribe not constant within caseid variable Roccupation not constant within caseid variable Reducation not constant within caseid variable REdithWealth not constant within caseid variable REdithSS not constant within caseid Your data are currently long. You are performing a reshape wide. You typed something like . reshape wide a b, i(caseid) j(TimeSeries) There are variables other than a, b, caseid, TimeSeries in your data. They must be constant within caseid because that is the only way they can fit into wide data without loss of information. The variable or variables listed above are not constant within caseid. Perhaps the values are in error. Type reshape error for a list of the problem observations. Either that, or the values vary because they should vary, in which case you must either add the variables to the list of xij variables to be reshaped, or drop them. r(9);
Is there any other way to conduct this regression? If not, is there code that would allow me to copy responses over from time 1 to time 0 for the same caseid?
Thank you for your help,
Christopher Tracey
Comment