I'm struggling to get my head around -reshape- (again).
I have data set up in long format as in the example below but want to reshape it wide so that I have male1, male2, male3 etc with one line per 'org_code'
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 org_code byte age long number_of_patients str9 ons_ccg_code str4 sex "A81001" 0 21 "E38000075" "MALE" "A81001" 1 22 "E38000075" "MALE" "A81001" 2 19 "E38000075" "MALE" "A81001" 3 24 "E38000075" "MALE" "A81001" 4 29 "E38000075" "MALE" "A81001" 5 8 "E38000075" "MALE" "A81001" 6 25 "E38000075" "MALE" "A81001" 7 26 "E38000075" "MALE" "A81001" 8 24 "E38000075" "MALE" "A81001" 9 19 "E38000075" "MALE" end
Code:
reshape wide number, i(org_code) j(age)
Code:
reshape wide sex, i(org_code) j(age)
variable number_of_patients not constant within org_code
Your data are currently long. You are performing a reshape wide. You typed something
like
. reshape wide a b, i(org_code) j(age)
There are variables other than a, b, org_code, age in your data. They must be constant
within org_code 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 org_code. 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);
Any help greatly appreciated
0 Response to Reshape wide error
Post a Comment