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

From |
"Eric A. Booth" <ebooth@ppri.tamu.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Making a table for percentage changes in stata |

Date |
Fri, 28 Aug 2009 14:15:28 -0500 |

Dana:

********************* clear all ssc install tab3way webuse auto rename rep78 age rename foreign var rename mpg sex recode sex (12/25 = 0) (25/.=1) gen AFTER = 1 if price<8000 recode AFTER (.=0) label def a 1 "post-", modify label def a 0 "pre-", modify label val AFTER a tab3way AFTER age sex, rowpct rowtot coltot allpct // OR maybe you want something more like: // forvalues n=1/2 { tab3way var age sex if AFTER==`n', rowtot coltot scoltot allpct } ***********************

You might find the table on page 15 of this .pdf particularly helpful: http://www.ianwatson.com.au/stata/tabout_tutorial.pdf Good luck, Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University ebooth@ppri.tamu.edu Office: +979.845.6754 On Aug 28, 2009, at 1:35 PM, Dana Chandler wrote:

Eric, Thanks for your response. Something very much like what you are describing is what I currently do. It just gets annoying because if you want to slice the data and show those percent differences for different groups, you have to then create different "base" and "end" values for each group. It'd be nice if somehow there was the same flexibility you have and could just write something like table AFTER age sex, c(mean var) pct Assume for a moment that AFTER is a pre/post variable and that age and sex are multichotomous. I'd then expect to see the values of var listed in the before and after state arranged by age and sex and with a new row that says pct change (from the AFTER variable). Maybe I'm too wishful. :) DanaOn Thu, Aug 27, 2009 at 8:35 PM, Eric A. Booth<ebooth@ppri.tamu.edu>wrote:I got ahead of myself---to make the 'pctdiff' variable I should have multiplied by 100, so it should read: foreach v in 1991 1992 { gen pctdiff_var`v' = (var`v'/base_var1990)*100 label var pctdiff_var`v' "Percent Change from `v' and 1990" } EAB On Aug 27, 2009, at 8:28 PM, Eric A. Booth wrote:Dana:I'm not sure that I completely understand how your data isstructured, butI would use -tabout- to get at your main question--that of easilycreatingan excel table of the average % changes in some variable between ayear anda base year (or before & after some year).I like to work with this kind of data in wide, rather than long,format,but you could adapt this same use of -tabout- to your data in longformat.********************** clear local sf `"`pwd'"' input year var 1990 3 1991 4 1992 5 1990 7 1991 15 1992 3.2 1990 9 1992 3 end //SET-UP gen id = [_n] reshape wide var, i(id) j(year) ** rename var1990 base_var1990 replace base_var1990 = base_var1990[_n-1] /* */ if base_var1990==. foreach v in 1991 1992 { gen pctdiff_var`v' = (var`v'/base_var1990) label var pctdiff_var`v' "Percent Change from `v' and 1990" } //TABOUT EXAMPLE tabout base_var1990 using "`sf'/test.xls", /* */ c(mean pctdiff_var1991 mean pctdiff_var1992) /* */ replace h1(TABLE Title) lines(double) f(2p) sum ********************** Best, Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University ebooth@ppri.tamu.edu Office: +979.845.6754 On Aug 27, 2009, at 7:32 PM, Dana Chandler wrote:Is there any module or easy way to calculate percentage changes in stata? That is to say, a percentage change relative to some base period. I am interested in an easy way to make a summary table of percent changes to have exported to either excel or powerpoint. Currently, supposing that my data has a "before" and "after" observation in long form and then any number of other potentialcategories, I either do a bunch of egens to create the totals andthencalculate the percent changes. Next, I "tag" whatever the unit ofobservation is and then I make a table showing the mean of thepercentchange. Alternatively, I could create and export a table that showsthe before and afters and then put that in excel and thencalculate %changes. Both processes seem really tedious. Is there any easy way to do this in Stata? Thanks in advance, Dana * * 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/* * 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/* * 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/* * 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/

**References**:**st: Making a table for percentage changes in stata***From:*Dana Chandler <dchandler@gmail.com>

**Re: st: Making a table for percentage changes in stata***From:*"Eric A. Booth" <ebooth@ppri.tamu.edu>

**Re: st: Making a table for percentage changes in stata***From:*"Eric A. Booth" <ebooth@ppri.tamu.edu>

**Re: st: Making a table for percentage changes in stata***From:*Dana Chandler <dchandler@gmail.com>

- Prev by Date:
**st: Nonlinear ordered probit interactions** - Next by Date:
**st: AW: "Conformability Error" when running svy:tabulate using over() option** - Previous by thread:
**Re: st: Making a table for percentage changes in stata** - Next by thread:
**st: suppress some results in latex table using outreg2 after 3sls estimation** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |