Statalist


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

st: RE: Parsing variable list into dependent and independent variables (logit)


From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   <[email protected]>
Subject   st: RE: Parsing variable list into dependent and independent variables (logit)
Date   Wed, 2 Apr 2008 08:07:59 -0500

Leif - Try the syntax below:

Note you should also initialize
local indepvars ""

before the loop. If you're working with strings, it's usually better to
not use "=" signs.


local indepvars "`indepvars' `indepvar'"

Al


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Peterson,
Leif
Sent: Tuesday, April 01, 2008 12:11 PM
To: [email protected]
Subject: st: Parsing variable list into dependent and independent
variables (logit)

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'"
  }
  logit `depvar' `indepvars'
end


Leif Peterson


NOTICE:  Our e-mail address at Methodist has changed to tmhs.org


Methodist. Leading Medicine. 

Ranked No. 10 on FORTUNE magazine's list of the "100 Best Companies to
Work For" in 2008
Named by U.S. News & World Report as one of "America's Best Hospitals"
Designated as a Magnet hospital for excellence in nursing

***CONFIDENTIALITY NOTICE***
This e-mail is the property of The Methodist Hospital and/or its
relevant affiliates and may contain confidential and privileged material
for the sole use of the intended recipient(s). Any review, use,
distribution or disclosure by others is strictly prohibited. If you are
not the intended recipient (or authorized to receive for the recipient),
please contact the sender and delete all copies of the message. Thank
you.



*
*   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/

*
*   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/



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