Announcement

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

  • Converting multiple rows of one variable into a single row

    Hi,

    I have a dataset on M&As in which one variable states the method of payment and another variable states the value of each method of payment.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str10 DealNumber str18 Dealmethodofpayment str17 DealmethodofpaymentvaluemU
    "1601434916" "Shares"      "60200"    
    ""           "Liabilities" "2500"     
    ""           "Bonds"       "5000"     
    ""           "Other"       "3500"     
    ""           "Cash"        "58890"    
    "1909123295" "Liabilities" "23300"    
    ""           "Shares"      "42700"    
    ""           "Cash"        "42700"    
    "1941097973" "Cash"        "35650"    
    ""           "Shares"      "35650"    
    ""           "Liabilities" "13800"    
    "1909646579" "Shares"      "20885.159"
    ""           "Liabilities" "8000"     
    ""           "Cash"        "48114.841"
    "1909133370" "Cash"        "n.a."     
    ""           "Liabilities" "27000"    
    ""           "Shares"      "n.a."     
    "1909098539" "Shares"      "33911.872"
    ""           "Liabilities" "n.a."     
    ""           "Cash"        "14533.66" 
    "1909147600" "Shares"      "n.a."     
    ""           "Cash"        "n.a."     
    "1909318540" "Shares"      "61694.671"
    "1909545396" "Shares"      "59000"    
    ""           "Liabilities" "n.a."     
    end
    Now, I want to create a single variable for these 2 variables so that i don't have multiple rows for each deal number. I would like to create one variable which states the method of payment on one row and another which states the value of the method of payment on one row. Both can be seperated by commas

    so to clarify, out of this data structure I would like to get 2 variables which state for example
    Method of payment: Shares, Cash, Liabilities
    Value of payment: 10, 5, 1

    Thanks in advance!

  • #2
    to be more precise, the goal is to have one row per deal and not 5 for example. If there is a better way to combine the rows of the method of payments, that's also fine

    Comment

    Working...
    X