Announcement

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

  • Exporting Variables to Excel

    Hi! I have created a few variables that I'd like to export to an excel file. I have variables rf1 through rf4 and fs and we1 through we4 . How do I create a table where my values are reported in rows so that the row reads Variable Name rf1 ---> fs ---> we1 and the row below is the next variable name ---> rf2 ---> fs ---> we2 .... and so on? My code so far is below (I'm saving the coefficients on variables from my regressions):

    regress workedm multi2nd, robust
    gen rf1=_b[multi2nd]
    regress hourswm multi2nd, robust
    gen rf2=_b[multi2nd]
    regress incomem multi2nd, robust
    gen rf3=_b[multi2nd]
    regress weeksm1 multi2nd, robust
    gen rf4=_b[multi2nd]

    *first stage
    regress morekids multi2nd, robust
    gen fs=_b[multi2nd]
    display fs
    gen we1=(rf1)/(fs)
    gen we2=(rf2)/(fs)
    gen we3=(rf3)/(fs)
    gen we4=(rf4)/(fs)

    display we1
    display we2
    display we3
    display we4


  • #2
    So, your "variables" rf*, fs, and we* are actually constants.

    Code:
    keep in 1
    keep rf* fs we*
    gen byte obs_no = _n
    reshape long rf we, i(obs_no)
    drop obs_no
    order _j, first
    // READY FOR YOUR EXPORT EXCEL COMMAND
    Note: This code eliminates the pre-existing data. You might want to -preserve- first and -restore- afterward if that data is needed for additional work.

    Comment

    Working...
    X