Hi,

I am trying to look at a range of numbers in a loop but am having difficulty.

My data looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str5 hcpcs
"84155"
"80051"
"80061"
"82040"
"82247"
"82565"
"83090"
"83615"
"84075"
"84155"
"84450"
"84460"
"84520"
"G0001"
"93000"
end
I am trying to write a loop that will look at 96400-96499 and 96500-96549.

I have tried a number of different things including:
foreach var of varlist hcpcs{
gen chemo = seq_o if `var' == "964**"

foreach var of varlist hcpcs{
gen chemo = seq_o if `var' == "964*"

foreach var of varlist hcpcs{
gen chemo = seq_o if `var' == "96400/96499"

seq_o is a number generated across all my observations from 1 to last person.

I have tried with and without quotation marks around the variable code. When I list out all the numbers my loop works but it is a lot to list out. Any help is appreciated. Sorry if this has been posted recently or I posted it incorrectly.

Thanks