On 4/1/08, Peterson, Leif <[email protected]> wrote:
> I am trying to run the mylogit.ado program (below) to parse a variable
> list and run logit regression. However, there is an exception being
> thrown at run-time which is called "+ invalid name."
>
> Example usage is:
>
> mylogit bloodpress age sexfem
>
>
> ----------------------------------
>
> program define mylogit,eclass
> version 10
> syntax [varlist]
> local ncol:word count `varlist'
> local depvar:word 1 of `varlist'
> forv i=2(1)`ncol' {
> local indepvar:word `i' of `varlist'
> local indepvars `indepvars' + "`indepvar'"
this line should be
local indepvars `indepvars' `indepvar'
so that the local `indepvars' is assigned the string composed of
`indepvars' and `indepvar'
> }
> logit `depvar' `indepvars'
> end
Your goals wil be acheived easier with -gettoken-:
gettoken depvar indepvars : varlist
will get you there in one line.
--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: Please do not reply to my Gmail address as I don't check
it regularly.
*
* 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/