Announcement

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

  • Independent double group indetifiers

    Hi everyone,

    I am trying different alternatives in order to achieve what I want in my data, but I am not able to do so...

    My problem is the next:

    I want to generate group identifiers on two variables, but not uniquely identified in the second. The uniquely identified would be the mix (concatenation) of both variables.

    The first variable corresponding to the client, the second variable to the commerce, I want that the second identifier (the commerce) start again the numbering every time that the client changes. If for instance there are 3 commerce on the same client, the enumeration would be 1, 2, 3. and when the next client appears, and there are 4 commerce in this client, the enumeration would be again 1, 2, 3, 4....

    I have tried with egen group, valid on the first identifiers (the client), but egen by client and commerce brings the same result that using the egen by commerce.


    Below an example, giving names of clients and commerce better than client1 client2, commerce1 commerce2, because I consider in this way is much more clarification and being WIW variable What I Want to achieve.

    [client] [commerce] [egen cod_client=group(client)] [egen cod_client=group(commerce)] [egen cod_client=group (client commerce)] [WIW]
    ONEBTW ONEBTW LASNAS 1 1 1 1
    ONEBTW ONEBTW LASNAS 1 1 1 1
    ONEBTW ONEBTW LASNAS 1 1 1 1
    ONEBTW ONEBTW LASNAS 1 1 1 1
    ONEBTW ONEBTW LASNAS 1 1 1 1
    ONEBTW ONEBTW LASNAS 1 1 1 1
    A.B.P. A.B.P. SALOM 2 2 2 1
    A.B.P. A.B.P. SALOM 2 2 2 1
    A.B.P. A.B.P. SALOM 2 2 2 1
    A.B.P. A.B.P. SALOM 2 2 2 1
    A.M. A.M. FUENEN 3 3 3 1
    A.M. A.M. FUENEN 3 3 3 1
    A.M. A.M. FUENEN 3 3 3 1
    A.M. A.M. ARREC 3 4 4 2
    A.M. A.M. ARREC 3 4 4 2
    A.M. A.M. ARREC 3 4 4 2
    A.M. A.M. LAPAM 3 5 5 3
    A.M. A.M. LAPAM 3 5 5 3
    A.M. A.M. LAPAM 3 5 5 3
    A.M. A.M. LAPAM 3 5 5 3
    ANOVA ANOVA PALO 4 6 6 1
    ANOVA ANOVA PALO 4 6 6 1
    ANOVA ANOVA PALO 4 6 6 1
    ANOVA ANOVA PALO 4 6 6 1
    ANOVA ANOVA TOGO 4 6 6 2
    ANOVA ANOVA TOGO 4 6 6 2

    Thank you in advance.

    Kyko Ortega

  • #2
    Please do read and act on http://www.statalist.org/forums/help#stata in giving data examples. Yours requires too much surgery to be easily run.

    This code, which you can run, seems analogous to your problem:

    Code:
    sysuse auto, clear
    bysort foreign rep78: gen myid = _n == 1
    by foreign: replace myid = sum(myid)
    list foreign rep78 myid, sepby(foreign rep78)

    Comment


    • #3
      Didn't know about this kind of format that the members have to follow....sorry....I will keep it in mind next time¡¡

      Thanks for your response and your help anyway¡¡¡It works perfectly¡¡



      Comment


      • #4
        The Statalist homepage carries this advice

        Please do read the Statalist FAQ for crucial advice before you try to post a message to Statalist. Knowledge of the FAQ will greatly improve the chance your question will be answered as you wish.
        Every time anyone starts a new thread there is a further prompt to read the FAQ Advice.

        We do mean what we ask....

        Comment


        • #5
          All right, I will take into account...Thanks again¡

          Comment

          Working...
          X