Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: creating a variable name from observations of a string variable


From   david parsley <[email protected]>
To   [email protected]
Subject   st: creating a variable name from observations of a string variable
Date   Thu, 20 Sep 2012 17:24:27 -0500

apparently my 1st attempt to post this did not work....I'm trying again.

I have a panel with a string variable identifying the cross-sectional
observations, e.g.,

state    X1    date
AK    70    1990
AL    35    1990
CA    110    1990
KY    56    1990

and I want to create a variable that compares the ith and jth
observations of x1 and
has its variable name taken from transformations of the string
variable 'state', e.g.,

RAKAL = X1(1)/X1(2)    1990
RAKCA = X1(1)/X1(3)    1990
RAKKY = X1(1)/X1(4)    1990
RALCA = X1(2)/X1(3)    1990
RALKY = X1(2)/X1(4)    1990
RCAKY = X1(3)/X1(4)    1990

I want to create all successive comparisons.  So far, I HAVE been able to create
variables R12, R13, R14, R23, R24, R34 using nested forvalues loops.

  by date: gen new`i's`j'=X1[`i']/X1[`j']


But, I'd rather have the variable name more reflective of what they actually are
by using the values of the 'state' variable.

I have searched and searched with no luck on this....Thanks.
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index