Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st:how to transfer a value to another dataset |
Date | Thu, 14 Jun 2012 09:31:19 +0100 |
I am unclear what you mean by a "constant variable", nor is it clear what -mppid- and -mcs- are in your data, but on one interpretation of your problem you just type gen double id = 4544 + _n gen double cs = 10646 + _n If the use of -double- here is mysterious, read http://blog.stata.com/tag/format/ You can also do this su ppid, meanonly local mppid = r(max) gen <whatever> = <something else> + `mppid' and so on. Nick On Thu, Jun 14, 2012 at 9:21 AM, Nina YIN <yinnina.ccer@gmail.com> wrote: > I want to define a constant variable in one data-set from a value > generated from another data file. How could I transfer the value > across files? > For example, I -sum ppid cs, > sum ppid cs > > Variable | Obs Mean Std. Dev. Min Max > -------------+-------------------------------------------------------- > ppid | 223566 2294.551 1314.803 1 4544 > cs | 223566 5323.5 3073.242 1 10646 > > now I got the maximum value of ppid and cs(mppid and mcs). > > Then I open another data, and need to generate variables which is > id=_n+mppid, cs=_n+mcs. How could I realize it? > > Local can only define the strings. I try to tostring mppid, and local > it , but it failed. * * 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/