Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Rename variables to reflect values?


From   "Victor, Jennifer Nicoll" <jnvictor@pitt.edu>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: Rename variables to reflect values?
Date   Thu, 4 Jun 2009 16:41:36 -0400

Hello Stata-users:

I have an NxN matrix where the first row of observations and first column of variables are essentially the labels/identifiers of the matrix.  Ultimately I will reshape this into a long format, but before I do I need the variable names to reflect the identifiers.  Right now the variable names are c2, c3, c4,...c256.  I'd like them to reflect the values in the first row of observations (or the first column--they are the same).  These values are a non-sequential sequence: 8, 10, 12, 14, 16....  So I'd like the variable names to be id8, id10, id12, id14...

I could make a local macro with the entire sequence and then do a foreach command with a rename function, but the sequence is very long (256 values long.)

Does anyone have a suggestion for how I could rename my variables to reflect the values in an observation or a variable?  Or any other suggested shortcuts, short of making this long local macro?

Thanks,
Jennifer

___________________________________________
Jennifer Nicoll Victor
Assistant Professor
Department of Political Science
University of Pittsburgh
4600 Wesley W. Posvar Hall
(412) 624-7204
E-mail:  jnvictor@pitt.edu
Homepage:  http://www.pitt.edu/~jnvictor



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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