Statalist The Stata Listserver


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

RE: st: RE: pairwise dummy variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: pairwise dummy variables
Date   Wed, 3 May 2006 14:15:30 +0100

Not sure I understand the query, but this 
illustrates the technique. 

local n = <whatever> 

forval i=1/`n' {
	local I=`i'+1
	forval j=`I'/`n' {
		gen byte sum_``i''_``j''= foo[`i'] + bar[`j'] 
	}
}

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Serguei
> Kaniovski
> Sent: 03 May 2006 14:08
> To: [email protected]
> Subject: RE: st: RE: pairwise dummy variables
> 
> 
> Nick, that you it works. Just a simple follow-up question: I have a 
> binary variable "binvar" with n observations. I would like to compute 
> the sums of the i-th and j-th element of "binvar", and put these into 
> separate variables named "sum_i_j" using a double loop:
> 
> forval i=1/n {
> local I=`i'+1
> forval j=`I'/n {
> ...
> gen byte sum_``i''_``j''=r(min)
> }
> }
> 
> What command should I use instead of the dots?
> 
> Thanks again,
> Serguei
> -- 
> ___________________________________________________________________
> 
> Austrian Institute of Economic Research (WIFO)
> 
> Name: Serguei Kaniovski			P.O.Box 91
> Tel.: +43-1-7982601-231			Arsenal Objekt 20
> Fax:  +43-1-7989386			1103 Vienna, Austria
> Mail: [email protected]
> 
> http://www.wifo.ac.at/Serguei.Kaniovski
> 
> *
> *   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