Hi all,
Perhaps someone can help me with this problem?
I have a location field in the data editor with many records for Fishing
Island, New Hampshire and Tizzard Island, Maryland.
I used
. levels location, local(uniqloc) separate(,)
When I display I get
. display "`uniqloc'"
The return (in green type on the monitor) has each element in compound
double quotes and each element separated with a comma.
. `"Fishing Island, New Hampshire"',`"Tizzard Island, Maryland"'
Then I use a foreach loop to sequentially use each element in the local
uniqloc
. foreach locat of local uniqloc {
If I display the value contained in locat
. display "`locat'"
Then the return is
. Fishing Island, New Hampshire
Which is exactly as it appears in the Data Editor
However, if I try all this in an ado file including the regression below ...
. regress pccov shootden if location == `"`locat'"'
Then I get no observations, even though I know there are observations.
If I type into the command window
. regress pccov shootden if location == `"`locat'"'
Then it works fine.
What's the difference? Where am I going wrong?
Thanks,
Steve
Stephen R. Hale, Ph.D.
Complex Systems Research Center
Institute for Study of Earth, Oceans, and Space
Morse Hall
University of New Hampshire
Durham, NH 03824-3525
Work 603.862.4758
Fax 603.862.0188
Home 603.664.4036
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/