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

st: RE: rename


From   "Nick Winter" <nwinter@policystudies.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: rename
Date   Tue, 19 Nov 2002 10:18:40 -0500

> -----Original Message-----
> From: Hans J. Baumgartner [mailto:hbaumgartner@diw.de] 
> Sent: Tuesday, November 19, 2002 10:13 AM
> To: statalist
> Subject: st: rename
> 
> 
> Hi statalisters,
> 
> I've got a new data file which is stored in an odd way.
> 
> I have imported the file using the command insheet-. As a 
> result I have 
> variable names v1 to v251. However, the first observation in 
> v251 is the 
> variable name for v1; the second observation in v251 is the variable 
> name for v2; and so on. Observation 251 and thereafter is missing.
> 
> I have tried:
> For num 1/250: rename vX v251 in X
> 
> But the rename- does not allow the in- option.
> 
> Any suggestions on this?
> 
> Thanks
> Hans

How about:

	forvalues x=1/250 {
		local name = v251[`x']
		rename v`x' `name'
	}

Nick Winter


-----------------------------------------------------------
 Nicholas Winter, Ph.D.                     P 202.939.5343
 Policy Studies Associates                  F 202.939.5732
 1718 Connecticut Avenue, NW     nwinter@policystudies.com
 Washington, DC 20009-1148           www.policystudies.com
----------------------------------------------------------- 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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