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
0 Response to Problem with reshape
Post a Comment