[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 |
Thu, 27 Aug 2009 20:35:07 -0500 |

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, but I would use -tabout- to get at your main question--that of easily creating an excel table of the average % changes insome variable between a year and a base year (or before & after someyear).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 datain long format.********************** 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 shows the before and afters and then put that in excel and then calculate % 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/

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

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

- Prev by Date:
**st: suppress some results in latex table using outreg2 after 3sls estimation** - Next by Date:
**st: RE: extracting month and year from a date variable** - Previous by thread:
**Re: st: Making a table for percentage changes in stata** - Next by thread:
**Re: st: Making a table for percentage changes in stata** - Index(es):

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