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   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: "If" in a local variable
Date   Tue, 30 Nov 2010 10:56:16 +0000

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index