Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Alternative to -collapse-?


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: Alternative to -collapse-?
Date   Tue, 23 Jul 2013 09:42:00 -0400

I think you want to look at -bysort- and -egen-. For example

 bysort id : egen v4=total(v3)

will generate your variable.

On 7/23/2013 9:10 AM, Lukas Borkowski wrote:
Dear list,

I am using Stata 12 and currently clean up a dataset that will become a panel dataset. The quality of the dataset is quite poor (originates from a survey) and I face multiple (endless) situations where values to the same questions are recorded in different variables. The tricky situations that I need to sum these values across rows and columns on a household level. The structure looks somewhat like this simplified example:

id	v1	v2	v3
1	.	.	2
1	.	7	.
1	9	.	.
2	4	.	1
2	.	7	.
2	7	.	.
...

I would like to generate a variable v4 that sums v3 on a household level. I currently use -collapse (sum) v3, by(id)- but this is obviously a real pain as I would have to merge all the resulting micro datasets.

Do you have any suggestion what I could do?

Thank you very much for your help!

Best,

Lukas

#
Lukas Borkowski
University of London, School of Oriental and African Studies (SOAS)





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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index