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, statalist.org is already up and running.


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

Re: st: Making a local with no assigned value zero


From   Nick Winter <nwinter@virginia.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Making a local with no assigned value zero
Date   Mon, 14 Jun 2010 21:12:16 -0400

I've seen things like the following in Stata ado code:

local x1 = `x1' + 0`y1'

Then when `y1' is empty, that becomes

local x1 = `x1' + 0

and when it's not, a zero is prepended to the value of y1, which is always the same as y1.

- Nick Winter


George Chioran wrote:
Dear statalisters, My code goes like
this: local x1 = `x1’ + `y1’. I get the `y1’ variable through repeated loops
and sometimes `y1’ is not assigned any value. When `y1’ does not
have any value, the line local x1 = `x1’ + `y1’ stops my program and I get an invalid
syntax error. My question is: Could
I somehow make the local `y1’ to be equal to zero, or not to be taken into
consideration in my sum in case `y1’ is not assigned any value? Thank you, George


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

--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  nwinter@virginia.edu e
University of Virginia          faculty.virginia.edu/nwinter w
S385 Gibson Hall, South Lawn  Map: http://tinyurl.com/uvaSLmap
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index