Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Joerg Luedicke <joerg.luedicke@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Combining 7 variables with the same output into a single frequency table |

Date |
Wed, 13 Feb 2013 18:00:46 -0500 |

With -egen, rowtotal()- you would add the values of your variables, which I believe is not what you want. Going from the example tables posted in the OP, then this might be what you want: *--------------------------- clear set obs 10 forval i = 1/3 { gen x`i' = runiform() > .7 } gen id = _n tab1 x* reshape long x, i(id) j(item) tab x *--------------------------- Joerg On Wed, Feb 13, 2013 at 5:00 PM, Astha Ramaiya <aramaiya@ihi.or.tz> wrote: > I want the sum of all variables (fever1 - fever7) categorized by 1 and 2. > > Would the code be the following: > > egen m_fever = rowtotal(m_fever1, m_fever2, m_fever3, m_fever5, m_fever6, m_fever7) to get the combined freq totals for "1" and combined freq totals for "2"? > > Thank you. > > Astha. > On Feb 13, 2013, at 4:47 PM, Richard Goldstein <richgold@ix.netcom.com> wrote: > >> it is not clear what you are looking for >> >> if you want the sum of the variables use -egen- with the rowtotal option >> >> if you want to know whether any of the variables have a "1", use -egen- >> with the rowmax option >> >> if you want something else, please clarify >> >> Rich >> >> On 2/13/13 4:39 PM, Astha Ramaiya wrote: >>> Dear Nicholas, >>> >>> I have 7 different variables (fever 1, fever 2, fever 3….fever7) with the same output (0=No, 1 = Yes). I want to combine all these variables so that i can calculate prevalence of the morbidity. For example: >>> >>> Fever 1-7 give the output: >>> >>> m_fever1 | Freq. Percent Cum. >>> ------------+----------------------------------- >>> 1 | 50 14.3 14.7 >>> 2 | 300 85.7 100.00 >>> ------------+----------------------------------- >>> Total | 350 100.00 >>> >>> >>> m_fever2 | Freq. Percent Cum. >>> ------------+----------------------------------- >>> 1 | 0 0 0 >>> 2 | 350 100.00 100.00 >>> ------------+----------------------------------- >>> Total | 350 100.00 >>> >>> m_fever3 | Freq. Percent Cum. >>> ------------+----------------------------------- >>> 1 | 100 28.6 28.6 >>> 2 | 250 71.4 100.00 >>> ------------+----------------------------------- >>> Total | 350 100.00 >>> >>> How can i combine the 3 tables above to give me the following table? >>> >>> m_fever | Freq. Percent Cum. >>> ------------+----------------------------------- >>> 1 | 150 14.3 14.7 >>> 2 | 900 85.7 100.00 >>> ------------+----------------------------------- >>> Total | 1050 100.00 >>> >>> I have been trying to find something the entire day but haven't been successful. Any help would be very much appreciated. >>> >>> Regards, >>> >>> Astha. >> * >> * 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/ > > > * > * 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/ * * 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/

**Follow-Ups**:**Re: st: Combining 7 variables with the same output into a single frequency table***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: Combining 7 variables with the same output into a single frequency table***From:*Astha Ramaiya <aramaiya@ihi.or.tz>

**Re: st: Combining 7 variables with the same output into a single frequency table***From:*Richard Goldstein <richgold@ix.netcom.com>

**Re: st: Combining 7 variables with the same output into a single frequency table***From:*Astha Ramaiya <aramaiya@ihi.or.tz>

- Prev by Date:
**st: RE: Cycling Through Regressions and Storing Residuals** - Next by Date:
**Re: st: Maximum likelihood estimation** - Previous by thread:
**Re: st: Combining 7 variables with the same output into a single frequency table** - Next by thread:
**Re: st: Combining 7 variables with the same output into a single frequency table** - Index(es):