Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: selecting variables by their format


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: selecting variables by their format
Date   Wed, 14 Sep 2005 21:56:06 +0100

"No observations" is here non-Stata language 
for "all missing", meaning all empty strings. 

String missings sort to the beginning. 

Thus all values of a string variable in a group of 
observations are missing if and only if the
last such value is missing after a -sort-
on that variable. 

Thus 

bysort location (var1) : gen byte allmiss = _n == _N & mi(var1) 
l location if allmiss 

Nick 
n.j.cox@durham.ac.uk 

TEWODAJ MOGUES
 
> Thanks much! The key new thing for me was -type-, which I 
> thought only 
> applies to whole datasets, not variables. This helped in sorting out 
> the string from the numeric variables, which allows me to 
> collapse the 
> numeric part of the dataset. As to the string part, I am still 
> wondering how I can collapse the original dataset, once purged of the 
> numeric variables, according to some string criteria. I want to 
> collapse them to give the highest "value" by some variable, say by 
> location. That is, if I have:
> 
> location    var1  var2
> place1      a      X
> place1      b      m
> place1      c      
> place2      f      2
> place2      F      5
> place2      9      10
> place3             k
> place3
> place3             p
> 
> after collapsing that should give:
> 
> location   var1   var2
> place1      c      m
> place2      f      2
> place3             p
> 
> The purpose of this is to see for which locations there are no 
> observations (in this case, it is for place3 in the case of var1).

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