Announcement

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

  • How to minimize identical successive observations ?

    Dear all,

    I'm working on a social policy for a job center. We are sending job recommendations to job seekers by mail according to their expected sector or a related sector.
    My database looks like :
    ID sector seek by the ID Company recommended sector of the company recommended
    1 a x a
    1 a x a
    1 a z a
    1 a y t
    2 z e r
    2 z e t
    2 z e u
    2 z z v














    Each job seekers would receive two mails with two companies recommended. I would like to find a way to re-sort my observations (keeping them sorted by ID) in a way
    that minimizes identical successive companies recommended; i.e. in the case above, invert the second obs with the third one in order to get two different companies recommended in the first mail and not the same ones (the first mail recommend the two first companies specific to each job-seekers, the second mail the two following ones, and so on).

    Thanks by advance,

    Faustin


  • #2
    I'm not sure if I understood it right, but, hazarding a guess, you may: a) use duplicates drop - to exclude duplicates; use - egen - with seq() function so as to select sequences of 2 for mailing.
    Best regards,

    Marcos

    Comment


    • #3
      You could try this:
      Code:
      egen tag = tag(id comp_recommended)
      sort id tag

      Comment


      • #4
        Thanks for your answers!!

        Indeed, I should develop a little bit more what I'm trying to do.. but it's quite difficult since I code the mail in HTML and I directly code varying part of the HTML code from that. But anyway, the important point is :

        We can have 5 differents cases of recommendations by mail :
        • Case 1 : 1 company from same sector seek and 1 company from related sector
        • Case 2 : 2 companies from same sectors
        • Case 3 : 2 companies from related sectors
        Sometimes some job-seekers would have the same company suggested 2, 3 or 4 times, and we don't want to put 2 same companies by mail, so we get two other cases (those I want to minimize) :
        • Case 4 : 1 company from same sector
        • Case 5 : 1 company from related sector
        From the database shown above, I do a reshape and get something like that (this allows me to create html code) :
        ID sector seek by the ID (rome_de) Company 1 Company 2 Company 3 Company 4 sector of company 1 (rome_bb1) sector of company 2 (rome_bb2) sector 3 sector 4
        1 a x x z y a a a t
        2 z e e e z r t u v
        The sector seek by job-seekers is constant and a company may be linked to different sectors. Then I identify my differents cases like this :


        gen Case_Mail_1 = .
        replace Case_Mail_1 = 1 if rome_de == rome_bb1 & rome_de == rome_bb2 & hyperlink1 != hyperlink2
        replace Case_Mail_1 = 2 if rome_de == rome_bb1 & rome_de != rome_bb2 & hyperlink1 != hyperlink2 | rome_de != rome_bb1 & rome_de == rome_bb2 & hyperlink1 != hyperlink2
        replace Case_Mail_1 = 3 if rome_de != rome_bb1 & rome_de != rome_bb2 & hyperlink1 != hyperlink2
        replace Case_Mail_1 = 4 if rome_de == rome_bb1 & rome_de == rome_bb2 & hyperlink1 == hyperlink2 | rome_de != rome_bb1 & rome_de == rome_bb2 & hyperlink1 == hyperlink2 | rome_de == rome_bb1 & rome_de != rome_bb2 & hyperlink1 == hyperlink2
        replace Case_Mail_1 = 5 if rome_de != rome_bb1 & rome_de != rome_bb2 & hyperlink1 == hyperlink2


        Where "rome_de" is the sector seek by the job-seekers, "rome_bb" is the sector linked to the company, and "hyperlink" is the hyperlink returning to the company website (but we can say it is the company). I do this again for the second mail, using rome_bb3 & rome_bb4 and hyperlink3 and hyperlink4.
        Since it's very difficult to build html code after the reshape, I have to find a way to reorganize my long database just before.

        I hope it was more clear, thanks again for your help !!

        Best regards,

        Faustin

        Comment

        Working...
        X