Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Dropping observations


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Dropping observations
Date   Thu, 17 Sep 2009 16:19:34 +0200

<> 

If ever your variable was indeed numeric, the case for turning them into
strings may be strong, but I think you could also stick to the numeric ones,
though I am willing to bow to superior wisdom here...


*************
clear*

inp myvar
0011 
8944 
4500 
3512
0989
end

//formatting not essential, but still...
format myvar %04.0f
list, noobs

//two leading zeroes
drop if myvar-mod(myvar,100)==0
list, noobs 

//one leading zero
drop if myvar-mod(myvar,1000)==0
list, noobs
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Ermias Ogbai
Weldemicael
Gesendet: Donnerstag, 17. September 2009 14:48
An: [email protected]
Betreff: st: Dropping observations

Dear Stata users,

I am trying to drop observation from one variable. The variable contains
four digit values (e.g. 0011 8944 4500 3512..). Is it possible to drop an
observation by if condition of the first digit..or first two digits. Like
'drop if value starts with 00'

Thanks,

Ermias O. Weldemicael
PhD student
University of Melbourne



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



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