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: Converting count to dichotomous variable
From
"Shittu, Aminu" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Converting count to dichotomous variable
Date
Sat, 10 Mar 2012 03:36:05 -0800 (PST)
Thank you very much Eric. I will try your suggestion when I returned to my desk. I am on transit now.
Have a nice weekend,
Aminu.
________________________________
From: Eric Booth <[email protected]>
To: [email protected]
Sent: Friday, March 9, 2012 10:23:31 PM
Subject: Re: st: Converting count to dichotomous variable
<>
Sorry, your mortalities were in var1, not var2, so the line:
bys day: egen var4_b = max(var2)
should have said:
bys day: egen var4_b = max(var1)
but the main point is the same.
EAB
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754
On Mar 9, 2012, at 3:57 PM, Eric Booth wrote:
<>
One strategy is to take the max number of mortalities (via -egen-) across all obs. in each day (or each pond/day -- I'm not sure which you need) and then recode anything greater than zero as a "1" indicating that mortalities occurred (leaving it as zero otherwise). Here a quick example:
***************!
clear
*--fake data
set obs 7
g var3 = _n
expand 365
sort var3
g var2 = int(30+runiform()*100)
g var1 = int(runiform()*4)
su var*
**var4**
*--daily mortality
by var3: g day = _n
*---1. for each pond/day
g var4_a = 1 if var1 != 0 //no mortalities each pond/day
replace var4_a = 0 if mi(var4_a)
*---2. for each day only
bys day: egen var4_b = max(var2)
recode var4_b (1/max = 1) (0=0)
su var4*
***************!
- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754
On Mar 9, 2012, at 3:30 PM, Aminu Shittu wrote:
Dear Statalisters,
I have var1 in my data set which represents number of death in a fish pond and var2 representing the existing number. The daily mortality was recorded in 7 fish ponds (var3) for a period of 1 year (365x7 rows). I am interested in creating a dichotomous var4, to indicate whether a daily mortality had occurred or not, without taking number of counts into consideration. Is it possible to do this in Stata or Excel?
Aminu.
*
* 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/