Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: diving values of a column with other values of the same column


From   Tzaloupas Dimitrov <tzaloupas1232@yahoo.gr>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: diving values of a column with other values of the same column
Date   Tue, 5 Feb 2013 21:34:32 +0000 (GMT)

 Dear all,
 
I have the following excel file which I import into Stata
 Country          overall         specific            dates                              values
DD                         gg           0             01/11/2001                               5
DD                         gg           0             01/12/2001                               2
DD                         gg           0             01/01/2001                               3
 DD                        gg           zz           01/11/2001                               15
DD                         gg           zz           01/12/2001                               12
DD                         gg           zz           01/01/2001                              13
EE                          gg           0             01/11/2001                               0.5
EE                          gg           0             01/12/2001                               0.2
EE                          gg           0             01/01/2001                               0.3
EE                          gg           zz           01/11/2001                               25
EE                          gg           zz           01/12/2001                               122
EE                          gg           zz           01/01/2001                              2 3
 
For each country  separately(DD and EE) I would like to   divide the values that correspond to specific==zz by the values that correspond to speciffic==0
 
For example, for DD I want to divide the vector  of values (15 12 13) that corresponds to specific==zz by the vector (5 2 3) that corresponds to specific==0; so as to construct a new vector of values=(15/5 12/2 13/3)
 
Similarly for the other country EE
 
 
I use Stata 11 and actually I have 200 countries. 
 
I assume that a loop is needed but this task is way ahead of my capabilities.
 
If  you can provide a specific code, I would be greatful
 
Regards,
tzaloupas

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index