Statalist


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

st: AW: data entries


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: data entries
Date   Wed, 20 May 2009 14:50:36 +0200

<> 



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

input str10 var  
"2011017:1"
"2011018:1"
"2011018:2"
"2011026:1"
"2011040:1"
"2011041:1"
end

compress
list, noobs  

gen newvar= substr(var,-1,.)
destring newvar, gen(mynewvar)
cou if mynewvar==2
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tunga Kantarci
Gesendet: Dienstag, 19. Mai 2009 23:37
An: [email protected]
Betreff: st: data entries

Hello,

I have a string variable whose entries look like as below: 

2011017:1
2011018:1
2011018:2
2011026:1
2011040:1
2011041:1

I need to determine how many of these entries have "2" at the end (i.e. as
you see above some entries have  ":1" and some others have ":2". I would
like to determine the number of entries with ":2" at the end.

What would be the command for this?


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