[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: reshaping a large number of variables
I need a bit of help reshaping a large number of variables. In my dataset I have a lot (>100) variables
ending in "v1", "v2", or "v3", representing variables for village 1, 2, or 3. Is there a quick way to reshape all these variables from this wide format into a long format, where each observation corresponds to a single village?
I was thinking to do something along this line:
*put all variable names in a local macro
unab mylist : *v1 *v2 *v3
*eliminate the trailing number from each name and put new names in a new local macro
*not sure how to do this
*reshape using the new local macro
reshape long `newlist', i(id) j(villagenr)
Any help is greatly appreciated.
* For searches and help try: