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

From |
Shehzad Ali <sia500@york.ac.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: AW: simple sum() question |

Date |
15 Apr 2009 16:54:45 +0100 |

Hi Martin and Josiane,

On Apr 15 2009, Martin Weiss wrote:

<>I am betting that you want a count of visits, not a running sum, butcorrect me if I am wrong...************* clear* set obs 400 egen float patient = seq(), from(1) to(400) block(4) egen float visit = seq(), from(1) to(4) block(1) //not strictly necessary xtset patient visit //less than 4 visits for some replace visit =. if runiform()<0.05 bys patient: egen overallvisits=count(visit) l in 1/20, sepby(patient) noo ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Shehzad Ali Gesendet: Mittwoch, 15. April 2009 16:48 An: statalist@hsphsun2.harvard.edu Cc: noman.paracha@gmail.com Betreff: st: simple sum() question Hi,I have a simple question about summing across observations. I have 100patients (variable: patient_id) in the dataset, each had clinic visits(variable: clinic) and hospital visits (variable: hospital) recorded atweeks 4, 8, 12 and 16. The dataset is long and hence I have 400observations (one observation per patient per time point).I want to sum the clinic visits for each patient (across all 4 visits)bearing in mind that some patients had less than 4 visits. So effectivelyI want to generate a new variable that will produce the sum of clinicvisits for each patient.Any help would be appreciated. Thank you, Shehzad * * 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/

-- Shehzad I Ali Department of Social Policy & Social Work University of York YO10 5NG +44 (0) 773-813-0094 * * 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**:**AW: st: AW: simple sum() question***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**RE: st: AW: simple sum() question***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: simple sum() question***From:*Shehzad Ali <sia500@york.ac.uk>

**st: AW: simple sum() question***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: AW: simple sum() question** - Next by Date:
**st: Data Management** - Previous by thread:
**st: AW: simple sum() question** - Next by thread:
**RE: st: AW: simple sum() question** - Index(es):

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