Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: A tricky reshape

From   "Nick Cox" <>
To   <>
Subject   st: RE: A tricky reshape
Date   Fri, 25 Jun 2004 12:53:17 +0100

I am not surprised that the stock
commands don't work. Your data don't 
yet satisfy the criteria for a -reshape-. 

A similar problem is discussed at
In essence, you need a mass re-naming. 

So long as you are using stubs 
Jan Feb Mar Apr May Jun Jul Aug Sep 
Oct Nov Dec, try this: 

di "`c(Mons)'"
tokenize `c(Mons)' 
forval i = 1/12 { 
	forval j = 1/7 { 
		rename ``m''X`j'  X`j'`m' 
gen i = _n 
reshape long X1 X2 X3 X4 X5 X6 X7, j(month) i(i) 


Hawken, Angela
> I'm struggling to reshape a dataset.  I need to go from wide 
> to long.  The
> format is:
> State JanX1 JanX2...JanX7...DecX6 DecX7
> State is a unique identifier.
> I need it in the form:
> State Month X1...X7
> This seemed simple when I started but the stock commands 
> don't seem to work.

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index