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: counting variables within a row
From
Steve Samuels <[email protected]>
To
[email protected]
Subject
Re: st: counting variables within a row
Date
Tue, 8 Jun 2010 20:07:28 -0400
Casey, you will probably get a quick answer if you substitute simple
variable names (e.g. x y z) for your long names and resend your post.
Steve
> *
--
Steven Samuels
[email protected]
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fax: 206-202-4783
On Tue, Jun 8, 2010 at 7:15 PM, Casey P. Durand <[email protected]> wrote:
> Hi folks,
>
> I have a dataset with 18 variables called met_aone-met_aeighteen.
> Within each observation, I'm trying to count the number of these
> variables with values which satisfy three criteria. I thought I could
> handle this with -egen- and the lines of code I originally wrote are:
>
> egen lightcount_d1= rownonmiss ( met_aone-met_aeighteen) if (
> met_aone-met_aeighteen)> 0 & ( met_aone-met_aeighteen)< 3
> egen modcount_d1= rownonmiss (met_aone-met_aeighteen) if
> (met_aone-met_aeighteen)>= 3.0000 & (met_aone-met_aeighteen)< 6
> egen hardcount_d1= rownonmiss (met_aone-met_aeighteen) if
> (met_aone-met_aeighteen)>= 6.0000 & (met_aone-met_aeighteen)< .
>
> The problem as I quickly realized is that it is only counting
> variables when every single value in the row satisfies the if
> requirement. What I can't figure out is how to assess each variable
> individually for meeting the criteria, but ultimately producing a new
> variable with the total within the observation which meets my
> criteria.
>
> Any thoughts on how to handle this?
>
> Thanks in advance.
>
*
* 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/