Announcement

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

  • Help please!! Reshaping data for event study

    Any help would be greatly appreciated- my master's dissertation is due soon and I am stuck!

    I am failing to reshape my data from wide to long and keep getting the 'no xij variables found' error, but can't figure out why. I presume it's because not every equity variable is matched by a date, though I cleaned the data quite extensively in R to prevent this from happening.

    As you can see in the data, I have a basket of firms and a market index for six events. I am looking to use the eventstudy2 package to conduct event study analysis for each event, and to aggregate the results.

    My code is below:

    import delimited "equitydata2.csv", clear

    reshape long eqix_us_equity adea_us_equity pcty_us_equity cvlt_us_equity panw_us_equity ftnt_us_equity gen_us_equity qlys_us_equity vrns_us_equity ospn_us_equity intz_us_equity adp_us_equity payx_us_equity ssys_us_equity inve_us_equity bkyi_us_equity viav_us_equity ntap_us_equity idcc_us_equity ffiv_us_equity ltrx_us_equity vsat_us_equity_28 feim_us_equity rbbn_us_equity adtn_us_equity dzsi_us_equity smci_us_equity ter_us_equity cohu_us_equity aehr_us_equity lrcx_us_equity acls_us_equity veco_us_equity uctt_us_equity asys_us_equity daio_us_equity amkr_us_equity axti_us_equity mpwr_us_equity powi_us_equity aosl_us_equity quik_us_equity atom_us_equity ipgp_us_equity qcom_us_equity ceva_us_equity amd_us_equity amba_us_equity lscc_us_equity vsat_us_equity_58 irdm_us_equity kvhi_us_equity ccoi_us_equity, i(date) j(firm)

    * Generate firmid after reshaping
    egen firmid = group(firm)

    * Generate returns
    bysort firmid: gen returns = D.value / L.value

    ....

    Many thanks
    Attached Files

  • #2
    https://stats.oarc.ucla.edu/stata/mo...-wide-to-long/

    Comment


    • #3
      The information at the link posted in #2 won't quite get you there--it doesn't cover the case where the "suffix" is actually, as here, a prefix.

      Also, before you can proceed with -reshape- you need to modify a couple of variable names that don't match the predominant pattern of firmname_us_equity.

      Code:
      rename vsat_us_equity_28 vsat_28_us_equity
      rename vsat_us_equity_58 vsat_58_us_equity
      
      reshape long @_us_equity, i(date) j(firm) string
      By the way, you will need to -xtset firmid date- before you can use the D. and L. operators.

      Comment

      Working...
      X