> This has been helpful in a lot of programming contexts.
> For instance, I currently pull out the variables that form
> the KCCQ survey scale by looping over ALL the variables
>
> foreach V of _all {
> local scale = V[scale]
> if "`scale'"=="KCCQ" {
> ...
> }
> }
>
I have a question related to your code:
local scale = V[scale]
does this work or did you simplify?
I get an error message, Stata does not know what
"scale" is, so I have to write
local scale = "`V[scale]'"
furthermore "V" is a local, the code would be:
local scale = "``V'[scale]'"
You could also use -ds-:
ds, has(char scale)
then the code would read:
/***************/
qui ds, has(char scale)
foreach v of varlist `r(varlist)' {
local scale = "``v'[scale]'"
if "`scale'"=="KCCQ" {
...
}
}
/***************/
Johannes
*
* 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/