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]

Re: st:how to transfer a value to another dataset


From   Nina YIN <[email protected]>
To   [email protected]
Subject   Re: st:how to transfer a value to another dataset
Date   Thu, 14 Jun 2012 10:46:46 +0200

Great!
It works well.
Thank you very much!  Nick.

On Thu, Jun 14, 2012 at 10:31 AM, Nick Cox <[email protected]> wrote:
> 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 <[email protected]> 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/



-- 
Best Regards,
Nina YIN


Toulouse School of Economics
Manufacture des Tabacs
21 Allee de Brienne
Toulouse, 31000, France
Tel: 0033-(0)5 6123 8348

*
*   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