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 on April 23, and its replacement, is already up and running.

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

RE: st: add up variable / quantile

From   "Scharnigg, Stan (Stud. SBE)" <>
To   "" <>
Subject   RE: st: add up variable / quantile
Date   Thu, 14 Apr 2011 17:55:05 +0200

aha, then is that the problem. Because var1 has 2.3 million observations and var2 has 5000 observation.
However, the values of var2 are more than once in var1.

I am gonna try this, thank you :)
Van: [] namens Nick Cox []
Verzonden: donderdag 14 april 2011 17:32
Onderwerp: Re: st: add up variable / quantile

gen var3 = var1 == var2

is certainly a good way to create a variable saying whether two
variables are the same. But what do you mean that "this is not

Note that -- necessarily -- this syntax compares values in the same
observation, and not in different observations.

gen var4 = var1 == var2[_n-1]

illustrates an extension which may be closer to what you seek.


On Thu, Apr 14, 2011 at 4:04 PM, Scharnigg, Stan (Stud. SBE)
<> wrote:
> I tried a different approach now. I created two new variables (var1, var2), and I want to use those
> two variables to create a third variable (var3). Var3 needs to be "1" if var1 has the same values as var2
> So I tried this:
> gen var3 = 0
> replace var3 = 1 if var1==var2
> However, this is not working. Is something like this possible in Stata?
> ________________________________________
*   For searches and help try:

*   For searches and help try:

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