Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: ranking variables on the basis of total values of observations


From   tashi lama <[email protected]>
To   <[email protected]>
Subject   RE: st: ranking variables on the basis of total values of observations
Date   Wed, 28 Mar 2012 20:53:50 +0000

Hello Nick, 

 

 Pls ignore my earlier mail since I did some clerical errors. Ok, so I have generated rumsum using (generate tot`var'=sum(`var')) and my dataset looks 

 

 

             date   var2   var3   var4   totalv~2   totalv~3   totalv~4 |
     |-----------------------------------------------------------------|
  1. | 05jan2010      3      1      7          3          1          7 |
  2. | 06jan2010      2      3      6          5          4         13 |
  3. | 07jan2010      4      4      5          9          8         18 |
  4. | 08jan2010      1      2      4         10         10         22 |
  5. | 09jan2010      5      8      3         15         18         25 |
     |-----------------------------------------------------------------|
  6. | 10jan2010      8      9      2         23         27         27 |
  7. | 11jan2010      4      6      3         27         33         30 |
  8. | 12jan2010      3      3      8         30         36         38 |
  9. | 13jan2010      1      2      3         31         38         41 |



 

 

 

Now, since I would like to rank var2 from 05jan2010 to 10jan2010, I would look at obs values of totalvar2 totalvar3 and totalvar4 at  date=10jan2010. As you can see totalvar2=23, totalvar3=27 and totalvar4=27,

var2 ranks 1st. The problem is I have to able to code and I am hoping you guys would give me some directions on this. 

 

Thank you again and let me know if I could make it any clearer. 

Tashi

 

 

 

 

 

 

 



----------------------------------------
&#62; Date&#58; Wed, 28 Mar 2012 21&#58;17&#58;19 &#43;0100&#13;&#10;&#62; Subject&#58; Re&#58; st&#58; ranking variables on the basis of total values of observations&#13;&#10;&#62; From&#58; njcoxstata&#64;gmail.com&#13;&#10;&#62; To&#58; statalist&#64;hsphsun2.harvard.edu&#13;&#10;&#62;&#13;&#10;&#62; I don&#39;t know what -rowsum- is here.&#13;&#10;&#62;&#13;&#10;&#62; Thanks, but this doesn&#39;t get me much closer. Of course, if other&#13;&#10;&#62; people can work out what you want, they should chip in.&#13;&#10;&#62;&#13;&#10;&#62; Please _show_ what you want it changed to, as I asked earlier. No&#13;&#10;&#62; word description, just what the dataset would like look after changes.&#13;&#10;&#62;&#13;&#10;&#62; Nick&#13;&#10;&#62;&#13;&#10;&#62; On Wed, Mar 28, 2012 at 8&#58;49 PM, tashi lama &#60;ltashi32&#64;hotmail.com&#62; wrote&#58;&#13;&#10;&#62;&#13;&#10;&#62; &#62; date var2 var3 var4&#13;&#10;&#62; &#62; 1. 05jan2010 3 1 7&#13;&#10;&#62; &#62; 2. 06jan2010 2 3!
  6&#13;&#10;&#62; &#62; 3. 07jan2010 4 4 5&#13;&#10;&#62; &#62; 4. 08jan2010 1 2 4&#13;&#10;&#62; &#62; 5. 09jan2010 5 8 3&#13;&#10;&#62; &#62; 6. 10jan2010 8 9 2&#13;&#10;&#62; &#62; 7. 11jan2010 4 6 3&#13;&#10;&#62; &#62; 8. 12jan2010 3 3 8&#13;&#10;&#62; &#62; 9. 13jan2010 1 2 3&#13;&#10;&#62; &#62;&#13;&#10;&#62;&#13;&#10;&#62; &#62; Say, I would like to rank var2 for certain period of time say &#40;05jan2010-09jan2010&#41;. So, I would have Stata add the obs values from 05jan2010 to 09jan2010 for all the variables and rank var2 like 1st or 2nd or 3rd. I looked at rowsum. I don&#39;t think it will help.&#13;&#10;&#62;&#13;&#10;&#62; &#62;&#62; Date&#58; Wed, 28 Mar 2012 20&#58;34&#58;58 &#43;0100&#13;&#10;&#62; &#62;&#62; Subject&#58; Re&#58; st&#58; ranking variables on the basis of total values of observations&#13;&#10;&#62; &#62;&#62; From&#58; njcoxstata&#64;gmail.com&#13;&#10;&#62; &#62;&#62; To&#58; statalist&#64;hsphsun2.harvard.edu&#13;&#10;&#62; &#62;&#62;&#13;!
 &#10;&#62; &#62;&#62; As far as I can see this could mean several thin

gs. I am not clear&#13;&#10;&#62; &#62;&#62; that when you say &#34;rank&#34; you don&#39;t mean &#34;order&#34; instead.&#13;&#10;&#62; &#62;&#62;&#13;&#10;&#62; &#62;&#62; I don&#39;t think you want -rowranks- &#40;SSC&#41;.&#13;&#10;&#62; &#62;&#62;&#13;&#10;&#62; &#62;&#62; Why not just give us a toy dataset, with say 5 observations and 5&#13;&#10;&#62; &#62;&#62; variables, and what you want to change it to&#63; Then it should be easier&#13;&#10;&#62; &#62;&#62; to see what you want.&#13;&#10;&#62; &#62;&#62;&#13;&#10;&#62; &#62;&#62; By the way, adding lots of blank lines just makes your posts more&#13;&#10;&#62; &#62;&#62; difficult to read. I&#39;ve edited what came in.&#13;&#10;&#62; &#62;&#62;&#13;&#10;&#62; &#62;&#62; Nick&#13;&#10;&#62; &#62;&#62;&#13;&#10;&#62; &#62;&#62; On Wed, Mar 28, 2012 at 8&#58;22 PM, tashi lama &#60;ltashi32&#64;hotmail.com&#62; wrote&#58;&#13;&#10;&#62; &#62;&#62; &#62;&#13;&#10;&#62; &#62;&#62; &#62; I have a list of variables and I wo!
 uld like to rank the variables or any given variable for that matter on the basis of total values of their observations. I thought of approaching this problem in the following way.&#13;&#10;&#62; &#62;&#62; &#62;&#13;&#10;&#62; &#62;&#62; &#62; 1. find the running sum of all the variables using generate or the total using egen although I think I would prefer generate.&#13;&#10;&#62; &#62;&#62; &#62;&#13;&#10;&#62; &#62;&#62; &#62; say there are var1 var2 var3&#13;&#10;&#62; &#62;&#62; &#62;&#13;&#10;&#62; &#62;&#62; &#62; gen tvar1&#61;sum&#40;var1&#41;&#13;&#10;&#62; &#62;&#62; &#62; gen tvar2&#61;sum&#40;var2&#41;&#13;&#10;&#62; &#62;&#62; &#62; gen tvar3&#61;sum&#40;var3&#41;&#13;&#10;&#62; &#62;&#62; &#62;&#13;&#10;&#62; &#62;&#62; &#62; 2. then compare tvar1, tvar2 and tvar3 using if conditions.&#13;&#10;&#62; &#62;&#62; &#62;&#13;&#10;&#62; &#62;&#62; &#62; Once this is done, I would like to expand such that I can rank those variables but for given period of time. And!
  this is essentially why I think generate sum is better for this probl

em because it is a running sum.&#13;&#10;&#62; &#62;&#62;&#13;&#10;&#62; &#62;&#62; &#62; say date var1 var2 var3&#13;&#10;&#62; &#62;&#62; &#62;&#13;&#10;&#62; &#62;&#62; &#62; I would like to be able to rank variables say for 01jan2011 to 01feb2011 and so on.&#13;&#10;&#62; &#62;&#62; &#62;&#13;&#10;&#62; &#62;&#62; &#62; Has anyone worked in this kind of problem before or does anyone have any idea or thought regarding this problem&#63; Any help or lead would be highly appreciated&#63; I saw that there is a stata module rowranks to calculate ranks in a row but i don&#39;t know how can it be useful to me. Most probably not....&#13;&#10;&#62;&#13;&#10;&#62; &#42;&#13;&#10;&#62; &#42; For searches and help try&#58;&#13;&#10;&#62; &#42; http&#58;//www.stata.com/help.cgi&#63;search&#13;&#10;&#62; &#42; http&#58;//www.stata.com/support/statalist/faq&#13;&#10;&#62; &#42; http&#58;//www.ats.ucla.edu/stat/stata/&#13;&#10; 		 	   		  
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index