I have a dataset (attached) that I am trying to reshape to long from wide. The data consist of aggregate numbers of of survey responses over time. I want a data set in long format such as:
Year(democratic position) (republican positio) (independent position) for each of three issues (race, the economy and religion):
Year (Dem Position) (Republican Position) (Ind Position)
for each issue. I typed:
. reshape long dempositionimportrace(year) dempositionXimporteco(year) dempositionimporwelfareyear) reppositionimportrace(year) repositionecoimport(year) repositionwelfareimport(year) indpositionimporteco(year) indposition > importrace(year) indpositionimportwelfareyear) ,i(id) j(year)
And got the result:
no xij variables found
You typed something like reshape wide a b, i(i) j(j).
reshape looked for existing variables named a# and b# but could not find any. Remember this picture:
long wide
+---------------+ +------------------+
| i j a b | | i a1 a2 b1 b2 |
|---------------| <--- reshape ---> |------------------|
| 1 1 1 2 | | 1 1 3 2 4 |
| 1 2 3 4 | | 2 5 7 6 8 |
| 2 1 5 6 | +------------------+
| 2 2 7 8 |
+---------------+
long to wide: reshape wide a b, i(i) j(j) (j existing variable)
wide to long: reshape long a b, i(i) j(j) (j new variable)
r(111);
Thanks for any help or suggestions. Do I have to type every variable separately and how do I enter year?
Ric Uslaner
Related Posts with Problem with reshape
Hypothesis testingHey there! I am currently trying to reproduce the estimation results of Alan Kruegers "Experimental…
Why no vIf in binary logistic RegressionDear Statalist, in my pursuit to asses whether there is multicollinearity in my model or not, I rea…
"Reshape" problems: non-constant number of variables over timeDear all, I looked for similar queries and couldn't find any, but of course, if you know of other "…
Event study - Dropping observations within a leads-lags frameworkHi Statalist users, I am conducting an event study where the outcome variable is the total number o…
Instrumental variable (IV) regression with categorical instrumented variable and continuous instrumentDear Stata Users, I need to apply instrumental variable (IV) cross sectional (country level) regres…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with reshape
Post a Comment