Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Extracting a variable of a varliable list


From   Thomas Corneli´┐Żen <[email protected]>
To   <[email protected]>
Subject   st: Extracting a variable of a varliable list
Date   Mon, 25 Jul 2005 17:43:04 +0200

Dear Stata Users,
I want to write an ado file using the -syntax- command as follows:

syntax varlist(min=2) [if] [in]

The first variable in varlist is the dependent variable, the others are the independent variables. I need to access them seperately in my ado-file.
Therefore I create a local that contains the name of the dependent variable, i.e. the first word of the varlist-string, and a local that contains all the rest and can be used as a varlist of only the independent variables.

local depvar=word("`varlist'",1)

local indepvar=substr("`varlist'",length("`depvar'")+1,length("`varlist'"));

My problem is that if the varlist is very long, it gets cut off at the 81st character. It seems that both the -length- and the -substr- function can only be applied to strings up to 81 characters.

I tried also to precede 'varlist' in the -syntax- command by 'varname', 'name' or 'anything' to capture the independent variable, but that returns error messages.

Can anybody suggest a better way to do what I want to do? Is there a good way of splitting one varlist into two varlists?
Thanks a lot for any suggestions!
Thomas

------------------------------------------------------------------
Thomas Cornelissen
Empirical Economic Research
University of Hannover, Germany
*
* 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