I am trying to reshape wide to long with a dataset that has multiple groups of variables, formatted with variables similar to the following:
Unique_ID Product1 Product1_Price Product1_Units Product1_Quantity Product2 Product2_Price Product2_Units Product2_Quantity .....etc. for many products.
I wish to reshape so the dataset contains only the following columns:
So far, I have tried the following code, but the vars Units Quantity and Price do not always align with each other, or with the correct product:
Unique_ID Product Price Units Quantity
import excel "Test.xlsx", sheet("Sheet1") firstrow case(lower)Please let me know if you have ideas for how to resolve, thank you!
reshape long product, i(unique_ID) j(product_number)
rename (*price) (price*)
rename (*units) (units*)
rename (*quantity) (quantity*)
reshape long price units quantity, i(unique_ID product_number) j(characteristics) string
order characteristics, last
0 Response to Reshape wide to long with multiple groups of variables
Post a Comment