Statalist The Stata Listserver


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

st: RE: unique string variables


From   "Rajesh Tharyan" <[email protected]>
To   <[email protected]>
Subject   st: RE: unique string variables
Date   Mon, 15 May 2006 20:21:26 +0100

Hi,

sort appyear code location
by appyear code location: gen noofloc=_N

gives


     | appyear    code   location   noofloc |
     |--------------------------------------|
  1. |    1972   66735         CA         1 |
  2. |    1972   71340        GBX         6 |
  3. |    1972   71340        GBX         6 |
  4. |    1972   71340        GBX         6 |
  5. |    1972   71340        GBX         6 |
     |--------------------------------------|
  6. |    1972   71340        GBX         6 |
  7. |    1972   71340        GBX         6 |
  8. |    1972   75065        GBX         2 |
  9. |    1972   75065        GBX         2 |
 10. |    1972   76070        JPX         4 |
     |--------------------------------------|
 11. |    1972   76070        JPX         4 |
 12. |    1972   76070        JPX         4 |
 13. |    1972   76070        JPX         4 |
 14. |    1972   76070         NJ         2 |
 15. |    1972   76070         NJ         2 |
     +--------------------------------------+

bigtab  appyear code location gives

  +--------------------------------------------------------------+
  | appyear    code   location   freq     pct   cumfreq   cumpct |
  |--------------------------------------------------------------|
  |    1972   66735         CA      1    6.67         1     6.67 |
  |    1972   71340        GBX      6   40.00         7    46.67 |
  |    1972   75065        GBX      2   13.33         9    60.00 |
  |    1972   76070        JPX      4   26.67        13    86.67 |
  |    1972   76070         NJ      2   13.33        15   100.00 |
  +--------------------------------------------------------------+



table code location, contents( freq ) by(appyear) gives 

----------------------------------
appyear   |        location       
and code  |   CA   GBX   JPX    NJ
----------+-----------------------
1972      |
    66735 |    1                  
    71340 |          6            
    75065 |          2            
    76070 |                4     2
----------------------------------

Etc..

Hope this helps

Regards
rajesh



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Mazhar Islam
Sent: 15 May 2006 20:01
To: Stata List
Subject: st: unique string variables 

Hi all,

I want to identify unique string variables within a
subgroup. I pasted a portion of data below.
Specifically I want to find how many locations a
certain code operates in a certain year. I will
appreciate any help.
Thanks
Mazhar 


appyear	code	location
1972	66735	CA
1972	71340	GBX
1972	71340	GBX
1972	71340	GBX
1972	71340	GBX
1972	71340	GBX
1972	71340	GBX
1972	75065	GBX
1972	75065	GBX
1972	76070	JPX
1972	76070	JPX
1972	76070	NJ
1972	76070	NJ
1972	76070	JPX
1972	76070	JPX


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   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