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: "If" in a local variable


From   Laurie Molina <[email protected]>
To   [email protected]
Subject   Re: st: "If" in a local variable
Date   Tue, 30 Nov 2010 08:32:35 -0600

Thank you all!
Exactly what i needed, sorry for the recycling i looked at the
internet for a solution but didnt find it so i came here, but
definitely next time i will look more carefuly...
Thanks again as always, see you


On Tue, Nov 30, 2010 at 4:56 AM, Nick Cox <[email protected]> wrote:
> This thread is recycling issues from a thread started on 17 November in
>
> <http://www.hsph.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist.1011/date/article-669.html>
>
> Nick
> [email protected]
>
> Maarten Buis
> ============
>
> An alternative to Eric's solution is to use the
> -cond()- function:
>
> local a = cond(`b' > `c', 1, 2)
>
> PS Just a clarification on terminology:
>
> Variables in Stata-speak are columns in a data-matrix.
> So `a' is not a "local variable", as it is not a column
> in a data-matrix. Instead it is a "local macro", often
> abreviated as a "local". Options are things that are
> placed after the comma in a command, so -if- is not
> an option. It is called a qualifier if it appears
> at the end of a command (but before the comma) and a
> command when it appears at the front.
>
> Eric Booth
> ==========
>
>> You can use the  -if- command instead of the "if"
>> qualifier.  See -help ifcmd-.   You probably want
>> this:
>>
>>      if `b' > `c'  local a= 1
>
>
> Laurie Molina
> =============
>
>> > I want to set the value of a local variable,
>> > conditional of the value of some other variable, but
>> > i think the option "if" is not availabe for a local
>> > variable.
>> > What i would like to do is the following:
>> > local a= 1 if `b' > `c'
>> > local a= 2 if `b' < = `c'
>
>
> *
> *   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/
>

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