Statalist The Stata Listserver


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

st: RE: RE: minimum of "all other variables"


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: minimum of "all other variables"
Date   Tue, 17 Oct 2006 09:23:22 +0100

But this is faster, as it reduces the 
interpretive overhead of ploughing through 
-egen- repetitively. 

unab myvars : price-foreign
qui foreach v of local myvars { 
	local others : list myvars - v 
	tokenize `others' 
	gen max_`v' = `1' 
	local others : list others - 1 
	foreach w of local others { 
		replace max_`v' = max(max_`v', `w') 
	} 
} 

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

Nick Cox
 
> unab myvars : ab-AB
> foreach v of local myvars { 
> 	local others : list myvars - v 
> 	egen max_`v' = rowmax(`others') 
> } 
 
Steve Vaisey
  
> > I have been wrestling with a problem for a while, and I've finally 
> > decided to bring it to you for what will probably be an 
> embarassingly 
> > quick solution. Here's the problem. Thanks to Nick, I have 
> a program 
> > (-myboolean-) that turns fuzzy sets into multiset fuzzy 
> > intersections. 
> > So, for example, with fuzzy sets A and B, running -myboolean A B- 
> > yields four new variables: ab Ab aB AB (where lower = absence 
> > [1-set], 
> > upper = presence [set], and -- for example -- AB = 
> min(A,B)). Enough 
> > background I hope.
> > 
> > What I'd like to do now is to create new variables that contain the 
> > maximum value of all OTHER configurations for each configuration 
> > produced by -myboolean-. Manually, this is easy to do: otherAB = 
> > max(Ab,aB,ab). But with 32 or 64 configuration variables, 
> > this is very 
> > time consuming. Is there a way to automate this so that:
> >      foreach var of varlist ab - AB {
> >      gen other`var' = max(***all other vars in varlist but `var'***)
> >      }
> > 
> > One final note: in the crisp set case (where set membership 
> is always 
> > 0/1) other`var' would always = 1-`var'. But this is not true in the 
> > fuzzy case. Hence the difficulty.

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