[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: A small technique problem
There a a couple of ways to do this:
1) don't have any other variables that begin with "dum" or choose a
different stub for the dummies, then you could just write:
local varlist_2 = "verbal_sat dum*"
2) Use the r(r) that tells you the number of dummies:
local varlist_2 = "verbal_sat dum1-dum`r(r)'"
----- Original Message -----
From: "Maoyong Fan" <email@example.com>
To: "statalist" <firstname.lastname@example.org>
Sent: Friday, June 11, 2004 3:35 PM
Subject: st: A small technique problem
> Dear Statalist members,
> I met a small stata problem. Does anyone have a good way to do it?
> The subprogram is like this:
> load big data set
> select small data set
> generate dum
> show how many dum variables are generated
> loop to operate on each dum
> In total, there are over fifty such small subprograms, every small data
set is different from the other.
> I have to check how many dums are there in the subprogram and put the
number into loop. Everytime, I change the big dataset, I have to recheck
the dum number and reinput the dum number into the loop.
> How can I let the stata do this automatically?
> Example of subprogram:
> use pdp_matching.dta, clear
> tabulate same_class, gen(dum)
> di r(r)
> local varlist_1 = "gender math_sat"
> local varlist_2 = "verbal_sat dum1-dum30"
> Note: I have to input 30 by myself before!!! Can stata do this
> Warm regards,
> Maoyong Fan
* For searches and help try: