Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: getting the quotes right

From   Finne Håkon <>
Subject   st: getting the quotes right
Date   Thu, 27 Jun 2002 00:39:27 +0200

Dear Statalisters,

I need to generate a command that eventually has the following structure:

list v1 if v2=="alpha" | v2=="beta" | v2=="gamma"

except that it is much longer (so it wraps over several lines) and is inside
a loop, so it will be repeated with a different number of different
conditional elements each time. So I try something like this (I write it in
the auto dataset terminology to facilitate testing):

local buicks (make=="Buick Century" | make=="Buick Electra" | make=="Buick
local datsuns (make=="Datsun 200" | make=="Datsun 210")
local vws (make=="VW Dasher" | make=="VW Rabbit" | make=="VW Scirocco")
local brands `buicks' `datsuns' `vws'
foreach brand of local brands {
	list price if `brand'

Of course this does not work. There are two issues (I think):
1) to make sure that
foreach number of local one two three {
makes the loop run three times and not eight or more
2) to get double quotes and compound double quotes in the right places.

The diagnostic phase of this problem is made more difficult because with
-display- the various quotes seem to be parsed differently from with -list-

Please, someone?

-- Håkon
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index