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]

Re: st: how to search every observation of one variable in another variable


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: how to search every observation of one variable in another variable
Date   Thu, 13 Jun 2013 03:31:55 -0400

clear
input long pt_no1 long pt_no      str1 owner byte           indicator
 10              20                      a                       0
 11              21                      a                       0
 21              22                      a                       1
 20              23                      a                       1
 20              24                      b                       0
 24              25                      b                       1
 25              26                      b                       1
 1               27                      c                       0
 3               28                      c                       0
 5               29                      c                       0
end

 tempfile dict
 preserve
 keep pt_no owner
 rename pt_no pt_no1
 sort pt_no1
 rename owner cited
 save `dict'

 restore
 sort pt_no1
 merge pt_no1 using `dict', nokeep
 tab _merge
 drop _merge

 gen ind=owner==cited
 assert indicator==ind

On Wed, Jun 12, 2013 at 7:07 PM, ibrahim bostan <[email protected]> wrote:
>  I have a dataset which have id number of patents applied by a firm and
>  the id number of patents cited by this patent. I am trying to have an
>  indicator, as below shown, which will equal one if patent applied by
>  the firm is citing a patent which is applied by the same firm.
>
>
>
>  cited pt_no   citing_pt_no      patent owner            indicator
>  10              20                      a                       0
>  11              21                      a                       0
>  21              22                      a                       1
>  20              23                      a                       1
>  20              24                      b                       0
>  24              25                      b                       1
>  25              26                      b                       1
>  1               27                      c                       0
>  3               28                      c                       0
>  5               29                      c                       0
>
> thanks
>  ibrahim
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index