In this case you are giving -inlist- a list a real numbers.
In addition, by using the -numlist- command your program will be able to
accept shorthand conventions for the number lists.
For example:
. foo invest mark, t(1/5 8 9) u(1/3 8/10)
The program will pass along the timex list of: 1, 2, 3, 4, 5, 8, 9 and the
units list of: 1, 2, 3, 8, 9, 10
program foo , rclass
version 9.2
syntax varlist(ts min=2 numeric) , Timex(numlist >=0 integer)
Units(numlist integer)
qui tsset
local tvar `r(timevar)'
local pvar "`r(panelvar)'"
numlist "`timex'", sort
numlist "`units'", sort
local tx: subinstr local timex " " ",", all
local u: subinstr local units " " ",", all
tempvar foo yx
gen `foo' = 1 if inlist(`tvar',`tx') & inlist(`pvar', `u')
qui mkmat `pvar' `tvar' `varlist' if `foo' == 1, matrix(`yx')
matrix list `yx'
end
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Tom Boonen
> Sent: Sunday, September 10, 2006 5:02 PM
> To: [email protected]
> Subject: Re: st: RE: extract rows from panel dataset
>
> Hi Scott,
>
> I have one more question: I don't understand why the infile() command
> works here.
>
> Specifically in your programm the expression:
>
> inlist(`tvar',`tx')
>
> `tvar' is a local that contains the timevariable and tx is a list of
> strings that contain the time numbers. In the help file it says that
> infile will only work if all arguments must be reals or all must be
> strings, which does not seem to be the case here.
>
> Can you please explain. This would be a great help for me to
> understand this potentialy powerfull command better.
>
> Thanks!
>
> Tom
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/