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]

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

From   "Nick Cox" <>
To   <>
Subject   st: RE: RE: Making a local with no assigned value zero
Date   Mon, 14 Jun 2010 21:14:52 +0100


local x1 = `y1' + `x1' 

(doesn't fit all problems, but might fit yours)


Nick Cox

There are various fixes. Here are some: 


if "`y1'" == "" local y1 = 0 
local x1 = `x1' + `y1' 


local x1 = cond("`y1'" != "", `x1' + `y1', `x1') 


if "`y1'" != "" local x1 = `x1' + `y1' 


George Chioran
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? 

*   For searches and help try:

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