Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: counting and immediately creating a new variable


From   "S.H. Former" <[email protected]>
To   [email protected]
Subject   st: counting and immediately creating a new variable
Date   Wed, 14 Sep 2011 11:19:45 +0200

Dear reader,
 
I have a question concerning counting data and representing this count immediately in a new cell. The design of my dataset looks as follows:
 
 
patent            value          complexity                   company           
3930280         34                               15              10679134                   
3930282         16                                8              10577942                    
3930283         12                               15             10577942                    
3930292          7                                20             10151655                    
3930294          4                                10             10680932                    
3930294          4                                10             10680932                    
3930297          34                               23           10105812                     
3930297          34                               23           10105812                     
3930299          1                                 5             10204962                    
3930304          58                               14           10046713                     
3930304          58                               14           10046713                     
3930304          58                               14           10046713                     
3930308          6                                 4              10140808                    
3930308          6                                 4              10140808                    
3930308          6                                 4              10140808                    
3930325          8                                 8              10446448                    
3930339          14                               4              10120593                    
3930344          9                                 8              10030344                    
3930359          5                                 3              10107775                    
3930367          21                               14            10446448                    
3930367          21                               14            10446448                    
3930367          21                               14            10446448                    
3930367          21                               14            10446448                    

Now I want to create a new variable where the number a patent is included in the database is counted. So it should look like this:
 
patent            value          complexity          company   New Variable       
3930280         34                        15          10679134                    1
3930282         16                         8           10577942                    1
3930283         12                         15         10577942                    1
3930292          7                          20         10151655                    1
3930294          4                          10         10680932                    2
3930294          4                          10         10680932                    2
3930297          34                        23         10105812                    2
3930297          34                        23         10105812                    2
3930299          1                           5         10204962                     1
3930304          58                         14        10046713                    3
3930304          58                         14        10046713                    3
3930304          58                         14        10046713                    3
3930308          6                          4          10140808                     3
3930308          6                          4          10140808                     3
3930308          6                          4          10140808                     3
3930325          8                          8           10446448                    1
3930339          14                         4          10120593                    1
3930344          9                           8          10030344                    1
3930359          5                           3          10107775                    1
3930367          21                         14        10446448                    4
3930367          21                         14        10446448                    4
3930367          21                         14        10446448                    4
3930367          21                         14        10446448                    4
 
So for example take patent 3930294, you can see that there are two patents with this number so the new variable should give 2!
 
Could please anyone help me with this problem?
 
thanks in advance,
 
Sytze



*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index