Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: simple way to count how many variables' value is uner 10 for a case


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: simple way to count how many variables' value is uner 10 for a case
Date   Mon, 16 Jun 2008 11:33:39 +0200

I fit is really only (positive?) integers we are talking about, why not

-egen belowten=anycount(var1 - var20), v(0/9)-


Martin Weiss
_________________________________________________________________

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen
Germany

Fon: 0049-7071-2978184

Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130

Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131

SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Man Jia
Sent: Monday, June 16, 2008 8:18 AM
To: [email protected]
Subject: st:simple way to count how many variables' value is uner 10 for a case

Hi all,

I was wondering if anyone could suggest a simple way to do the 
following job.

The data set is like this:
-----------------------------------------------------------------------
caseid   var1        var2          var3     var4 .........         var10

 1          6             8              9         15    ...            
    11
 2          3             4              5          7     ...           
      0
 3          1             2             10        14    ...             
   26
 .           .             .                .           .               
           .
 .           .             .                .           .               
           .
 .           .             .                .           .               
           .
------------------------------------------------------------------------

I want to find out for each case totally how many times the values for 
var1,var 2....var20 are under 10.
I think I could creat dummy variables defining 1 for those variable's 
value is under 10. That is as follows:
-----------------------------------------------------------------------
caseid  new_var1  new_var2  new_var3  new_var4 ...new_var10
 1          1             1             1            0      ...         
0
 2          1             1             1            1      ...         
1
 3          1             1             0            0      ...         
0
 .           .             .                .           .               
    .
 .           .             .                .           .               
    .
 .           .             .                .           .               
    .
------------------------------------------------------------------------
And then I could creat a new variable as sum_var=new_var1 + new_var2 
+.....+new_var10  

My question is, is there any way more simple than this? 

Thanks!

Man Jia
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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