[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

[no subject]

One way to do what you want grows out of the fact that you are not
obliged to feed -foreach- a varlist. You could feed it an arbitrary
list, of which one item might be 

"payor_1  payor_2 payor_3 payor_4 payor_5 payor_6"



And then you work on each item, expanding it to a varlist as necessary. 

This sounds like the sort of problem for which working out a clever way
to do it consumes far more time than letting Stata crunch its way


Jeph Herrin

I have hundreds of variables that I need to loop through
and process. Some of them are grouped together because they
represent different options that are not mutually exclusive;
for example, "Insurance type: check all that apply:" has
results stored in:


I have a datum -type- associated with each that tells me it is part of a
"multiselect" (sic) question, so when I loop through all my variables:

   foreach V of varlist `biglist' {
	if `type'=="M" {
		<do stuff>

The ... handles every other types of variable. However, when I
<do stuff> I'd like to handle all the variables in that particular
group, eg, payor_1-payor_6. I can do this, but then I need to advance
the -foreach- to the variable *after* payor_6.

One thought I had was to reference the variables by their number, which
is available via -describe, number- (I'd have to -keep `biglist'- first)
but I'm not sure how to refer to a variable by its number, and can't
find any info on how to do so.

Does anyone see how to make this idea - or any other- work so I can skip
ahead in a -foreach- loop?

*   For searches and help try:

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