Announcement

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

  • Master thesis

    Good day everyone!

    I am currently writing my master thesis and for the first time I am using Stata to analyze a data set.
    The background information on the individual variables and the foreach loop are secondary for now. My big problem is the following: Stata creates a matrix with all variables I want to have. However, the results are not saved in my desired file path. Every time I try to save something, the destination remains empty. What am I doing wrong?
    Thank you in advance.

    Best regarrds from Germany
    Florian



    PHP Code:
    ```stata
    foreach var of varlist 
    $employed_phasen  {
    local l
    `var' : variable label `var'
    matrix drop _all
    reg 
    `var' treat1_or treat2_or if adm_v2==2&drop==0 & women==1
    matrix M = r(table)

    local pvalue_3x4 = M["pvalue", "treat1_or"]
    local pvalue_3x5 = M["pvalue", "treat2_or"]

    test treat1_or=treat2_or

    local pvalue_diff_3x6=r(p)

    local btreat1_or = M["b", "treat1_or"]
    local setreat1_or = M["se", "treat1_or"]
    local btreat2_or = M["b", "treat2_or"]
    local setreat2_or = M["se", "treat2_or"]

    cap drop esam1
    cap gen esam1=e(sample)==1
    matrix drop _all
    mean 
    `var' if control_or==1&esam1==1&drop==0

    test `var'
    local pvalue_3x1=r(p)

    local ncontrol_or=e(N)
    matrix mcontrol_or=e(b)
    local mcontrol_or=mcontrol_or[1,1]
    matrix msecontrol_or=e(V)
    local msecontrol_or=msecontrol_or[1,1]

    matrix drop _all
    mean 
    `var' if treat1_or==1&esam1==1&drop==0 

    test 
    `var'
    local pvalue_3x2=r(p)
    *
    local  ntreat1_or=e(N)
    matrix  mtreat1_or=e(b)
    local  mtreat1_or= mtreat1_or[1,1]
    matrix  msetreat1_or=e(V)
    local  msetreat1_or= msetreat1_or[1,1]
    matrix drop _all
    mean `var' 
    if treat2_or==1&esam1==1&drop==
    *
    test `var'
    local pvalue_3x3=r(p)
    *
    local ntreat2_or=e(N)
    matrix mtreat2_or=e(b)
    local mtreat2_or=mtreat2_or[1,1]
    *
    matrix msetreat2_or=e(V)
    local msetreat2_or=msetreat2_or[1,1]

    matrix a0
    `var'=(`mcontrol_or',`mtreat1_or',`mtreat2_or',`btreat1_or',`btreat2_or',. \ `msecontrol_or',`msetreat1_or',`msetreat2_or',`setreat1_or',`setreat2_or',. \ `pvalue_3x1',`pvalue_3x2',`pvalue_3x3',`pvalue_3x4',`pvalue_3x5', `pvalue_diff_3x6' \ `ncontrol_or',`ntreat1_or',`ntreat2_or', `n_a',.,. )

    matrix list a0
    `var'  

    matsave a0`var'
    , `"C:\Users\Florian Frankl\Desktop\MA\Outputs"'  
    restore


  • #2
    You have the syntax all wrong in your -matsave- command. It should be -matsave- followed by the name of the file you want to save them in, followed by the name of the matrix. And there should be no commas separating those.

    Comment

    Working...
    X