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

From |
Dana Chandler <dchandler@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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

Date |
Fri, 28 Aug 2009 13:35:31 -0500 |

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. :) Dana On 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 is structured, but >> I would use -tabout- to get at your main question--that of easily creating >> an excel table of the average % changes in some variable between a year and >> a 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 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 potential >>> categories, I either do a bunch of egens to create the totals and then >>> calculate the percent changes. Next, I "tag" whatever the unit of >>> observation is and then I make a table showing the mean of the percent >>> change. 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/ > * * 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:*"Eric A. Booth" <ebooth@ppri.tamu.edu>

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

- Prev by Date:
**Re: "Official", "documented", and so forth [was: RE: st: AW: listing variables with certain characteristics]** - Next by Date:
**st: "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:
**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 |