Statalist The Stata Listserver


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

st: RE: stata 8 - strings


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: stata 8 - strings
Date   Wed, 12 Apr 2006 13:46:42 +0100

I guess the issue arises with the loop 

foreach x in `eqtvar`ic'' {
	local XX = subinword("`Xu'","`x'","",1)
	local Xu `XX'
}

You should familiarise yourself with the material
at -help macrolists-. 

What you want would seem to be 

foreach x of local eqtvar`ic' { 
	local Xu : list Xu - x 
}

The key difference is inside the loop. I've rewritten
the outside purely as a reflection of stylistic preference. 

Nick 
n.j.cox@durham.ac.uk 

PM McKee

> I am programming a simultaneous equation model and are 
> generating the reduced form equations by constructing the 
> union of different sets of variables.
> Since there is a large number of variables involved we are 
> exceeding the stata limit on string lengths of 244.
> I have got round the problem by renaming variables using 
> shorter names but we wonder is there a more satisfactory alternative?
> 
> Below is the code we have used.
> 
> * creating the set of Reduced Form variables for each 
> structural equation Xu1 etc
> forvalues ir = 1/`nofrowsinA'{
> local notset = 0
> forvalues ic = 1/`nofcolsinA' {
> if structeqt[`ir',`ic']==1 & `notset' == 0{
> * joining sets of variables - first lot
> * eqtvar`ic' is the list of exogenous variables in struct eqt ic
> local Xu " `eqtvar`ic'' "
> local notset = 1
> }
> else if structeqt[`ir',`ic']==1 & `notset' == 1{
> * for each variable in the next lot -
> * if it appears in the first lot blank it out
> foreach x in `eqtvar`ic'' {
> local XX = subinword("`Xu'","`x'","",1)
> local Xu `XX'
> }
> local XX " `Xu' `eqtvar`ic'' "
> local Xu " `XX'"
> }
> }
> local Xu`ir' "`Xu'"
> sum `Xu`ir''
> }

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index