Announcement

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

  • Collapse and counting the same observation

    Hi I am analyzing the data set that have the name of organizations, the name of EMR vendors and the 7 different functions.
    I would like to see whether organization use the same vendors for 7 different functions or not.
    If they are not using the same vendors for different functions, I would like to see how many vendors that they are using.
    In case they are using different vendors,
    If they are using the same vendor for more than 5 functions out of 7 functions, I would like to consider that vendor for the vendor that the organization selected. want to keep only that vendor as one observation per each organization.

    id is the variable for the organization id
    application is the variable for the different functions
    vendor is the variable for the name of vendors.

    Could you please help me in this?
    Last edited by jykim; 16 Apr 2014, 17:49.

  • #2
    Assuming that for every unique id, there are 7 observations (rows) corresponding to each of the 7 functions:

    Code:
    egen tag = tag(id vendor)  // tag unique
    bysort id : egen n_vendors = total(tag)   // Number of vendors used
    
    bysort id vendor : gen times_used = _N    // Number of times a vendor is used 
    keep if times_used >= 5 & tag == 1   // Keep only one observation per organization
    drop application  // You might as well drop this, cos it's not relevant any more.

    Comment


    • #3
      Thank you so much Mark
      It was really helpful!!!! Your explanation solved a lot of my problems.

      Last edited by jykim; 17 Apr 2014, 13:57.

      Comment

      Working...
      X