No announcement yet.
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generation of variable that copies value if condition is met

    Hello everyone,

    I find it hard to find a solution which I believe shouldn't be that difficult to solve. Below you find a shortened version of my data for my master's thesis, which is enough to demonstrate my problem.

    patent cusip year citing ncited nciting patentechclass
    3930413 14999Z 1973 5086813 5 10 x3
    3930413 14999Z 1973 6986433 5 10 x3
    3930413 14999Z 1973 5269342 5 10 x3
    3930413 14999Z 1973 6715624 5 10 x3
    3930413 14999Z 1973 4253336 5 10 x3

    I have merged datasets on CUSIP, which is the company identifier. Per CUSIP, I have variables such as executive compensation and union representation. I also have data on their patents and the class to which the patent belongs. For every patent it is given how many times it has been cited and how many times it cites another patent. The variable "citing" in this case indicates which patent has cited patent 3930413.

    What I need however, are the 10 patent numbers that patent 3930413 makes citations to as well as the classes of these patents. Patent number 3930413 would occur somewhere in "citing". Thus, I would need a new variable "citingbypatent". This would take on the value of "patent" if citing corresponds to 3930413 in this case.

    Does any of you know how to make this happen? As in this case the rows per patent should be expanded from 5 to 10, would this be a problem?

    Thank you in advance.

  • #2
    Forgive me if I misunderstands you, but would something like the below writen example help ?

    keep patent citing patentchclass
    rename patent citingbypatent
    rename citing patent
    save dataset_for_citing.dta, replace
    * reload original dataset
    joinby patent using dataset_for_citing.dta, unmatched(master) _merge(_merge)
    it can probably be made easier.


    • #3
      That does indeed solve the matter! Thanks a lot.