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" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
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 
n.j.cox@durham.ac.uk 

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Serguei
> Kaniovski
> Sent: 03 May 2006 14:08
> To: statalist@hsphsun2.harvard.edu
> 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: Serguei.Kaniovski@wifo.ac.at
> 
> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index