I am trying to use the reshape command on the data attached, but I keep receiving this error.
Code:
reshape long a, i(combined) j(prod, string) (note: j = a aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az b ba bb bc bd be bf bg bh b > i bj bk bl bm bn bu bv bw bx by bz c ca cb cc cd ce cf cg ch ck cl cm cn co cp cq cr cs ct cu cv cw cx cy cz d da db > dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz e ea eb ec ed ee ef eg eh ei ej ek el em en > eo ep eq er es et eu f g h i j k l m n o p q r s t u v w x y z)
Code:
variable id does not uniquely identify the observations Your data are currently wide. You are performing a reshape long. You specified i(combined) and j(prod). In the current wide form, variable combined should uniquely identify the observations. 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 | +---------------+ Type reshape error for a list of the problem observations. r(9);
My goal of this code is to create a "prod" variable with all of the variable names (such as "White bread, 1 kg (supermarket)") inputted as individual entries underneath the "prod" variable. The reason I have 2 rows which (one of which has variable names aa, ab, ac, etc. and the other with the actual product names themselves, "White bread, 1 kg (supermarket)," is due to STATA's 32 character limit. It was causing me issues, so I tried to work around it by reshaping with an additional row.
I would also like to make another variable "store_type" in which it either says "supermarket" or "mid-priced store" and no longer having this information captured in the individual data entires themselves. So, to clarify, in the end I would have variables: year, country, city, currency, prod, and store_type. Under "prod" it would display "White bread, 1 kg," for example, and under "store_type" it would show either "supermarket" or "mid-priced store."
I'm sorry if this is a simple question--I'm just becoming more familiar with STATA and appreciate any and all suggestions you all may have.
Many thanks,
Jim
EIU submit attempt.dta
Submit EIU clean.do
5EIU Data.xlsx
0 Response to Reshape error: variable id does not uniquely identify the observations
Post a Comment