Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, is already up and running.

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

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

From   Nick Cox <>
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

You can also do this

su ppid, meanonly
local mppid = r(max)
gen <whatever> = <something else> + `mppid'

and so on.


On Thu, Jun 14, 2012 at 9:21 AM, Nina YIN <> 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:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index