Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: if vs if

From   Kit Baum <>
Subject   st: Re: if vs if
Date   Sat, 17 Apr 2004 11:30:43 -0400

On Apr 17, 2004, at 2:33 AM, Renzo wrote:

I would like to do the following thing
. local macroname = var1 if var2==value
This is not legal syntax though. I looked on [U] and [P] to see if there
were any extended macro function to help me but I did not find any.

You are confusing the 'if' that may appear as a component of many Stata commands, e.g. summarize income if sex==1, and the programmer's 'if'. Furthermore, since each observation of var2 may take on a different value, what does it mean to generate one macro with value equalling the first observation of var1 in this context? Do you mean if any observation of var2 takes on 'value'? Or if all observations of var2 are equal to 'value'?

Your workaround looks only at the first observation of var2. Is that what you really mean? Please clarify.


* For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index