Announcement

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

  • option over() not allowed

    Hello all,

    My colleague sent me a .do file (which works - at least on his dataset, which is different to mine) and I'm trying to adjust to my needs. However, I am getting the following error message:

    Code:
    option over() not allowed
    r(198);
    This is my code...

    Code:
    svyset [pweight=weight]
    
    /*    Gender    */
    matrix gen_seg=J(10,2,.)
    set more off
    local i=1
    foreach gend in  dummy1 dummy2 dummy3 dummy4 dummy5 dummy6 dummy7 dummy8 dummy9 dummy10     {
    di `gend'
    svy: mean `gend', over(gender)
    mat temp=r(table)
    local j=1
    while `j'<3        {
    matrix gen_seg[`i',`j']=temp[1,`j']
    *matrix gen_seg[`i',2*`j']=temp[2,`j']
    local j=`j'+1
    }
    local i=`i
    
    mat rowname gen_seg =  dummy1 dummy2 dummy3 dummy4 dummy5 dummy6 dummy7 dummy8 dummy9 dummy10
    mat colname gen_seg = male female
     
    
     
    }
    
    mat list gen_seg
    mat t_gen_seg = gen_seg'
    mat list t_gen_seg
    
    putexcel B1=("Segment") using "${descrip}/LIC_rawdesc.xlsx", sheet("ind_ch")replace
    #delimit ;
    putexcel B2=("Employed with SS and PL") C2=("Employee without SS and PL") D2=("Employee without SS and PL (IS)")
    E2=("SE Formal Urban") F2=("SE Informal Urban") G2=("SE Formal Rural")
    H2=("SE Informal Rural") I2=("Unpaid family worker") J2=("Agriculture Private Sector")
    K2=("Own Account - Agriculture") ) using "${descrip}/LIC_rawdesc.xlsx", sheet("ind_ch") modify ;
    #delimit cr
    putexcel A3=("Male") B3=matrix(t_gend_seg) using "${descrip}/LIC_rawdesc.xlsx", sheet("ind_ch") modify
    putexcel A4=("Female") using "${descrip}/LIC_rawdesc.xlsx", sheet("ind_ch") modify
    This is my colleague's code (which works)

    Code:
    /* Gender */
    
    matrix gen_seg=J(13,4,.)
    set more off
    local i=1
    foreach gend in fsempb fsseemployb fsseoeb forpvthhb fsinformempb isempb isseemployb isseoeb infpvthhb unphhb unemployedb discouragedb neab {
    di `gend'
    svy: mean `gend', over(gender)
    mat temp=r(table)
    local j=1
    while `j'<3 {
    matrix gen_seg[`i',2*`j'-1]=temp[1,`j']
    matrix gen_seg[`i',2*`j']=temp[2,`j']
    local j=`j'+1
    }
    local i=`i'+1
    
    mat rowname gen_seg = fsempb fsseemployb fsseoeb forpvthhb fsinformempb isempb isseemployb isseoeb infpvthhb unphhb unemployedb discouragedb neab
    mat colname gen_seg = male se female se
    
    }
    
    mat list gen_seg
    mat t_gen_seg = gen_seg'
    mat list t_gen_seg
    
    putexcel A11=("Male") B11=matrix(t_gen_seg) using "${descrip}/ELLA_rawdesc.xlsx", sheet("ind_ch") modify
    putexcel A13=("Female") using "${descrip}/ELLA_rawdesc.xlsx", sheet("ind_ch") modify
    Last edited by Chris Rooney; 09 Sep 2015, 03:30.

  • #2
    I don't have a direct answer to your question about the source of the error because you haven't post any data so we can reproduce the same error.
    However, this kind of code for exporting summary statistics to Excel is very easy and flexible with user written programs such as tabout (also support for svy data).
    take a look at this manual for some examples. to install, type: ssc install tabout

    Comment

    Working...
    X