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: RE: Making a local with no assigned value zero
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
RE: st: RE: Making a local with no assigned value zero
Date
Mon, 14 Jun 2010 22:33:02 +0200
<>
You forgot the quotes around the thing which NJC had suggested:
if "`y1'" == ""{
These objects are not variables, btw, but -local-s.
HTH
Martin
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Chioran
Sent: Montag, 14. Juni 2010 22:26
To: [email protected]
Subject: Re: st: RE: Making a local with no assigned value zero
Dear Nick,
Thank you for the reply. However I do not seem to manage to make the `y1 ' variable equal to nothing. When I type:
if `y1' == "" {
local y1 = 0
}
I get an error saying type mismatch, and I assume it is because the " " symbol is maybe not recognized as no value? Did I type it in wrong, or would there be another way of saying that `y1' is equal to nothing? Do you also know how I can delete/drop locals once I create them?
Thanks,
George
----- Original Message ----
From: Nick Cox <[email protected]>
To: [email protected]
Sent: Mon, June 14, 2010 10:08:38 PM
Subject: st: RE: Making a local with no assigned value zero
There are various fixes. Here are some:
1.
if "`y1'" == "" local y1 = 0
local x1 = `x1' + `y1'
2.
local x1 = cond("`y1'" != "", `x1' + `y1', `x1')
3.
if "`y1'" != "" local x1 = `x1' + `y1'
Nick
[email protected]
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:
* 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/
*
* 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/