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

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

From |
Caliph Omar Moumin <sheikmoumin@yahoo.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: How to reshape or collapse multiple observation per id as one observation per id |

Date |
Sun, 12 Aug 2012 11:17:25 -0700 (PDT) |

Dear Aminu How do i keep other variables like gender, agegroup, and other string variables? Kind Regards, Caliph Omar Moumin Email: sheikmoumin@yahoo.com ----- Original Message ----- From: "Shittu, Aminu" <ameen_vet@yahoo.com> To: "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> Cc: Sent: Sunday, August 12, 2012 6:03 PM Subject: Re: st: How to reshape or collapse multiple observation per id as one observation per id Dear Caliph Try this one: collapse (sum) duration cost, by(id) Aminu ________________________________ From: Caliph Omar Moumin <sheikmoumin@yahoo.com> To: "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> Sent: Sunday, August 12, 2012 4:42:42 PM Subject: st: How to reshape or collapse multiple observation per id as one observation per id Dear statalist helper I want to ask your help about a command which many of you answered many times, but i couldn´t i understand well. it is ´reshape´or ´collapse´ command. I have a dataset which is in long format with multiple observation per id, and no time period. The dataset is also unbalanced id duration cost gender agegroup plus other string variables (up to 5 variables) I want to create a dataset with one observation per id by adding each ones multiple observation in both variables duration and cost id duration cost (other variables) 1 8 50 string(or constant) 1 10 40 >>>>>>>>>>>>> 1 3 30 >>>>>>>>>>>>> 2 7 20 >>>>>>>>>>>>> 2 9 60 >>>>>>>>>>>>> 2 6 100 >>>>>>>>>>>>>> 2 8 20 and so on up to 20,000 observation which i have one up to 10 observation per id. I wanted to reshape my dataset as Id duration cost (other variables) 1 21 120 unchanged 2 30 200 >>>>>>>>> I tried the reshape command. And it is creating many variables of duration and cost instead of adding as one variable id duration1 duration2 duration3 duration4........... 1 8 10 3 . I tried the collapse command and it is giving me only the mean value. But i wanted the total value. I would appreciate you if you could help? Kind Regards, Caliph Email: sheikmoumin@yahoo.com * * 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: How to reshape or collapse multiple observation per id as one observation per id***From:*"Shittu, Aminu" <ameen_vet@yahoo.com>

**References**:**st: How to reshape or collapse multiple observation per id as one observation per id***From:*Caliph Omar Moumin <sheikmoumin@yahoo.com>

**Re: st: How to reshape or collapse multiple observation per id as one observation per id***From:*"Shittu, Aminu" <ameen_vet@yahoo.com>

- Prev by Date:
**st: New version of package -scheme_rbn1mono- for SSC** - Next by Date:
**Re: st: How to reshape or collapse multiple observation per id as one observation per id** - Previous by thread:
**Re: st: How to reshape or collapse multiple observation per id as one observation per id** - Next by thread:
**Re: st: How to reshape or collapse multiple observation per id as one observation per id** - Index(es):