Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to create a new variable which contains the response from anot=


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: How to create a new variable which contains the response from anot=
Date   Mon, 5 Mar 2007 11:02:05 -0500

Chiung-Ya Tang--
You should not send rich formatting to Statalist--the FAQ advises that
this is a text-only list--and it is easy to choose not to in gmail.
As for your question, see -help _variables- for use of _n e.g.

clear
input gp   id   v1
     1    1    3.2
     1    2    4.5
     2    1    3.1
     2    2    3.3
     3    1     .
     3    2    2.3
end
bys gp (id): g v2=v1[3-_n]
l, noo clean


On 3/5/07, Chiung-Ya Tang <[email protected]> wrote:
[gibberish]
I am learning STATA and would like to use it to analyze a set of dyadic dat=
a. The data is as following:

Group    member        V1
=E3=80=801       1            3.2
=E3=80=801       2            4.5
=E3=80=802       1            3.1
=E3=80=802       2            3.3

I wish to generate a new variable--V2 in which responses from V1 are exchan=
ged within a group. So, it should look like this:

Group         member          V1      V2
=E3=80=801              1            3.2     4.5
=E3=80=801              2            4.5     3.2
=E3=80=802              1            3.1     3.3
=E3=80=802              2            3.3     3.1
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index