Announcement

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

  • Summarize Variables

    Hi,

    I'm am trying to get the frequency of several dummy variables in one single table on Stata 13. I have the variables (SequenceA SequenceB SequenceC SequenceD SequenceE SequenceF SequenceF SequenceG SequenceH SequenceI SequenceJ SequenceK) that can take a value of 1 or 0, and every row can only have one of these variables with value 1. I'm trying to group them in a way that it counts the total number of times 1 appears (among all of them) and then the percentage of SequenceA from the total and so forth, but all in one table. Additionally, I want to add other columns with means of these sequences, such as Leverage, Cashflows, etc whenever the SequenceA, Sequence B, and so forth take a value of 1. Is that even possible? I have days trying to figure this out. Many thanks for your help.

    Regards,

    Peter
    Last edited by Peter Mueller; 07 Jun 2018, 13:48.

  • #2
    Hello Peter. As it says in the FAQ, you'll stand a better chance of getting good help if you provide a sample of what the data look like now, and what you want it to look like afterwards. I'm not sure I understand what you want to do, but here's a guess at it. HTH.

    Code:
    * Generate some sample data
    clear *
    input byte SequenceA SequenceB SequenceC SequenceD SequenceE
    0 0 0 0 0
    0 0 0 0 0
    0 0 0 0 1
    0 0 0 1 0
    0 0 1 0 0
    0 1 0 0 0
    0 1 0 0 0
    1 0 0 0 0
    1 0 0 0 0
    1 0 0 0 0
    end
    
    egen byte seq = group(SequenceA - SequenceE)
    generate byte seqrev = 7-seq
    list
    tabulate seq seqrev
    Output from -list- command above:

    . list

    Code:
         +---------------------------------------------------------------------+
         | Sequen~A   Sequen~B   Sequen~C   Sequen~D   Sequen~E   seq   seqrev |
         |---------------------------------------------------------------------|
      1. |        0          0          0          0          0     1        6 |
      2. |        0          0          0          0          0     1        6 |
      3. |        0          0          0          0          1     2        5 |
      4. |        0          0          0          1          0     3        4 |
      5. |        0          0          1          0          0     4        3 |
         |---------------------------------------------------------------------|
      6. |        0          1          0          0          0     5        2 |
      7. |        0          1          0          0          0     5        2 |
      8. |        1          0          0          0          0     6        1 |
      9. |        1          0          0          0          0     6        1 |
     10. |        1          0          0          0          0     6        1 |
         +---------------------------------------------------------------------+
    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 18.5 (Windows)

    Comment


    • #3
      Hi Bruce.

      Thank you for your help. I'll keep your advice in mind, next time I ask for help.

      regards,

      Peter

      Comment

      Working...
      X