Statalist The Stata Listserver


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

st: Tagging the combination number


From   "Rodrigo Martell" <[email protected]>
To   <[email protected]>
Subject   st: Tagging the combination number
Date   Thu, 19 Oct 2006 13:12:16 +1000

I suspect my last email didn't get through since I can't get it in my outbox and can't find it in the archives. I'm re-sending it hoping it will work this time.
Apologies if it's a duplicate. Thanks.

-----------------------------------------------------------------

Hi all,
 
I'm trying to figure out how to incorporate a combination number when filling out a table. I've attached a little program that I've been using to test what I'm trying to do (the code is part of a bigger program).
Here's my attempt at trying to explain the problem:
 
Essentially, the program creates log(var) and unique pairwise combinations of log(var i)-log(var j) where i != j.
The program also creates lcol1 to lcolnum60 and lrcolnum1 to lrcolnum60, which are variables that are meant to store a lot of stuff as part of the bigger program.
lcolnum* and lrcolnum* essentially build a table of results. I want to have the names of the log(variables) and combinations of log ratios (log(vari)-log(varj)) in the first column of lcolnum or lrcolnum, i.e. in lcolnum1 and lrcolnum1. Notice that I leave the first two rows blank because other stuff goes in there as part of the bigger program.
 
The program successfully does this for each log(var) - i.e. lcolnum1 - but the pairwise combinations are a bit trickier. I'm trying to get something that tells me the combination number (I've called it "obsrow") so that I can add 2 to it and fill out lrcolnum1. 
 
If anyone has any ideas I'd appreciate them shooting them my way.
 
Thanks!
 
Rodrigo
 
Here's the code:
*************************************************************************************************
capture program drop fillit

capture drop l*

program define fillit

syntax varlist

local nvars : word count `varlist'

forvalues i = 1/60{

qui gen lcolnum`i' = ""

}

qui replace lcolnum1 = "" in 1

qui replace lcolnum1 = "" in 2

**********4.1B Generate output space for results******

forvalues i = 1/60{

qui gen lrcolnum`i' = ""

}

qui replace lrcolnum1 = "" in 1

qui replace lrcolnum1 = "" in 2

foreach var of local varlist{

qui gen log_`var'=log(`var')

}

forvalues i = 1/`nvars'{

local s = `i'+2

qui replace lcolnum1 = "log_``i''" in `s'

}

******************This part creates unique pairwise combinations of variables in varlist and places the name in the first column********

forvalues i=1/`nvars'{

local ii=`i'+1

forvalues j=`ii'/`nvars'{

gen log_``i''_vs_log_``j''=log(``i'')-log(``j'')

***Here is where my problem comes up. I want obsrow to be the combination number +2 but I can't figure out how to do it. I'd appreciate a hand :=)****

*local obsrow = (combination number)+2

*replace lrcolnum1 = "log_``i''_vs_log_``j''" in `obsrow'

}

}

end

************************************************************************************************
Rodrigo Martell

 <http://www.frontier-economics.com> 	
Frontier Economics Pty. Ltd.
395 Collins Street
Melbourne VIC 3000
Australia
www.frontier-economics.com 	
switch:
direct:
fax:
mobile:
email:


+61 (0)3 9620 4488
+61 (0)3 9613 1518
+61 (0)3 8614 2711
+61 (0)407 909 811
[email protected] <mailto:[email protected]> 


This e-mail, including any attachments, may contain confidential and privileged information for the sole use of the intended recipient(s). Any review, use, disclosure or distribution by others is strictly prohibited. If you are not the intended recipient (or authorised to receive information for the recipient), please contact the sender by reply e-mail and delete all copies of this message. Thank you.

	


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