Statalist


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

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


From   Man Jia <jia.m@neu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st:simple way to count how many variables' value is uner 10 for a case
Date   Mon, 16 Jun 2008 02:17:43 -0400 (EDT)

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/



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