Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: AW: no observations R 2000 error


From   Dias Marios <[email protected]>
To   [email protected]
Subject   Re: st: AW: no observations R 2000 error
Date   Sat, 4 Jul 2009 01:25:58 -0700 (PDT)

Hi,

seems that id is running ok from 1 to 85. I have put -set trace on- but i am afraid i don't understand much. Seems like some versions are missing but i have no idea what these are. What does version stand for?

Thank you 

THIS IS THE OUTPUT I GET

. set trace on

. set more off 

. 
. gen predicted_return=.
(13686 missing values generated)

. 
. egen id=group(company_id) 
--------------------------------------------------------------------------------------- begin egen ---
- version 6, missing
- gettoken type 0 : 0, parse(" =(")
- gettoken name 0 : 0, parse(" =(")
- if `"`name'"'=="=" {
= if `"="'=="=" {
- local name `"`type'"'
= local name `"id"'
- local type : set type
- }
- else {
  gettoken eqsign 0 : 0, parse(" =(")
  if `"`eqsign'"' != "=" {
  error 198
  }
  }
- confirm new variable `name'
= confirm new variable id
- gettoken fcn 0 : 0, parse(" =(")
- gettoken args 0 : 0, parse(" ,") match(par)
- if `"`par'"' != "(" {
= if `"("' != "(" {
  exit 198
  }
- if `"`args'"' == "_all" {
= if `"company_id"' == "_all" {
  version 7.0, missing
  unab args : _all
  local args : subinstr local args "`_sortindex'" "", all word
  version 6.0, missing
  }
- syntax [if] [in] [, *]
- if _by() {
  local byopt "by(`_byvars')"
  local cma ","
  }
- else if `"`options'"' != "" {
= else if `""' != "" {
  local cma ","
  }
- tempvar dummy
- global EGEN_Varname `name'
= global EGEN_Varname id
- version 7.0, missing
- global EGEN_SVarname `_sortindex'
= global EGEN_SVarname __000000
- version 6.0, missing
- capture noisily _g`fcn' `type' `dummy' = (`args') `if' `in' `cma' `byopt' `options'
= capture noisily _ggroup float __000001 = (company_id)     
  -------------------------------------------------------------------------------- begin _ggroup ---
  - version 7, missing
  - gettoken type 0 : 0
  - gettoken g 0 : 0
  - gettoken eqs 0 : 0
  - syntax varlist [if] [in] [, Missing BY(string) Label LName(name) Truncate(numlist max=1 int >= 1
> )]
  - if `"`by'"' != "" {
  = if `""' != "" {
    _egennoby group() `"`by'"'
    }
  - if "`truncate'" != "" & "`label'" == "" {
  = if "" != "" & "" == "" {
    di as err "truncate() option requires the label option"
    exit 198
    }
  - if "`lname'" != "" {
  = if "" != "" {
    local label "label"
    }
  - tempvar touse
  - quietly {
  - mark `touse' `if' `in'
  = mark __000002  
  - if "`missing'"=="" {
  = if ""=="" {
  - markout `touse' `varlist', strok
  = markout __000002 company_id, strok
  - }
  - sort `touse' `varlist'
  = sort __000002 company_id
  - quietly by `touse' `varlist': gen `type' `g'=1 if _n==1 & `touse'
  = quietly by __000002 company_id: gen float __000001=1 if _n==1 & __000002
  - replace `g'=sum(`g')
  = replace __000001=sum(__000001)
  - replace `g'=. if `touse'!=1
  = replace __000001=. if __000002!=1
  - if "`label'"!="" {
  = if ""!="" {
    if "`lname'" == "" {
    local lname $EGEN_Varname
    unab lab_name_list : _all
    foreach var of local lab_name_list {
    local lab : value label `var'
    local lab_list `lab_list' `lab'
    }
    local dup_check : list lname in lab_list
    if `dup_check' {
    di as err "you must specify the lname() option"
    exit 198
    }
    }
    local dfltfmt : set dp
    local dfltfmt = cond("`dfltfmt'"=="period","%9.0g","%9,0g")
    count if !`touse'
    local j = 1 + r(N)
    sum `g', meanonly
    local max `r(max)'
    local i 1
    while `i' <= 0`max' {
    tokenize `varlist'
    local vtmp " "
    local x 1
    while "`1'"!="" {
    local vallab : value label `1'
    local val = `1'[`j']
    if "`vallab'" != "" {
    local vtmp2 : label `vallab' `val' `truncate'
    }
    else {
    cap confirm numeric var `1'
    if _rc==0 {
    local vtmp2 = string(`1'[`j'],"`dfltfmt'")
    }
    else {
    if "`truncate'"=="" {
    local vtmp2 = trim(`1'[`j'])
    }
    else {
    local vtmp2 = trim(substr(trim(`1'[`j']),1,`truncate'))
    }
    }
    }
    local x = `x' + length("`vtmp2'") + 1
    local vtmp "`vtmp' `vtmp2'"
    mac shift
    }
    local val `vtmp'
    label def `lname' `i' "`val'", modify
    count if `g' == `i'
    local j = `j' + r(N)
    local i = `i' + 1
    }
    label val `g' `lname'
    }
  - }
  - if length("group(`varlist')") > 80 {
  = if length("group(company_id)") > 80 {
    note `g' : group(`varlist')
    label var `g' "see notes"
    }
  - else label var `g' "group(`varlist')"
  = else label var __000001 "group(company_id)"
  ---------------------------------------------------------------------------------- end _ggroup ---
- global EGEN_SVarname
- global EGEN_Varname
- if _rc { exit _rc }
- quietly count if missing(`dummy')
= quietly count if missing(__000001)
- if r(N) {
  local s = cond(r(N)>1,"s","")
  di in bl "(" r(N) " missing value`s' generated)"
  }
- rename `dummy' `name'
= rename __000001 id
--------------------------------------------------------------------------------------- end egen ---

. 
. 
. 
. forvalues i=1(1)85 { 
  2. 
. l id company_id if id==`i' & dif==0
  3. 
. reg ret market_return if id==`i' & estimation_window==1 
  4. 
. predict p if id==`i'
  5. 
. replace predicted_return = p if id==`i' & event_window==1 
  6. 
. drop p
  7. 
. }
- forvalues i=1(1)85 {
- l id company_id if id==`i' & dif==0
= l id company_id if id==1 & dif==0

       +---------------+
       | id   compan~d |
       |---------------|
  121. |  1          1 |
       +---------------+
- reg ret market_return if id==`i' & estimation_window==1
= reg ret market_return if id==1 & estimation_window==1
-------------------------------------------------------------------------------------- begin reg ---
- if _by() {
  local by "by `_byvars'`_byrc0':"
  }
- `by' regress `0'
=  regress ret market_return if id==1 & estimation_window==1
  -------------------------------------------------------------------------------- begin regress ---
  - version 9, missing
  - local version : di "version " string(_caller()) ", missing :"
  - if _by() {
    local BY `"by `_byvars'`_byrc0':"'
    }
  - syntax [anything] [if] [in] [aw fw iw pw] [, VCE(passthru) Robust CLuster(passthru) * ]
  - if `:length local vce' {
  = if 0 {
    `version' `BY' _vce_parserun regress, mark(CLuster) : `0'
    if "`s(exit)'" != "" {
    ereturn local cmdline `"regress `0'"'
    exit
    }
    _vce_parse, argopt(CLuster) opt(OLS Robust HC2 HC3) old : [`weight'`exp'], `vce' `robust' `clust
> er'
    if "`r(cluster)'" != "" {
    local cluster cluster(`r(cluster)')
    }
    else if "`r(vce)'" != "ols" {
    local robust = "`r(vce)'"
    }
    local vce = cond("`r(vce)'" != "", "`r(vce)'", "ols")
    }
  - else if "`cluster'" != "" {
  = else if "" != "" {
    local vce cluster
    }
  - else if "`weight'" == "pweight" | "`robust'" != "" {
  = else if "" == "pweight" | "" != "" {
    local vce robust
    }
  - else local vce ols
  - if replay() {
    if _by() {
    error 190
    }
    `version' Display `0'
    exit
    }
  - `version' `BY' _regress `anything' `if' `in' [`weight'`exp'], `options' `robust' `cluster'
  = version 10, missing :  _regress ret market_return if id==1 & estimation_window==1  [],   
no observations
  ---------------------------------------------------------------------------------- end regress ---
---------------------------------------------------------------------------------------- end reg ---
  predict p if id==`i'
  replace predicted_return = p if id==`i' & event_window==1
  drop p
  }
r(2000);

. edit
- preserve


--- On Fri, 7/3/09, Martin Weiss <[email protected]> wrote:

> From: Martin Weiss <[email protected]>
> Subject: st: AW: no observations R 2000 error
> To: [email protected]
> Date: Friday, July 3, 2009, 8:14 AM
> 
> <> 
> 
> Could be several things, but it is critically important for
> the list to know
> after which line Stata complains. Also, you could -set
> trace on- and report
> the area around the error. 
> 
> Are you sure you have id running from 1 to 85? Type
> -levelsof id- to check!
> If one of them is missing, the -reg- command throws up an
> error and stops
> the whole thing... You can prevent this by adding -capture-
> in front of the
> command in question...
> 
> 
> 
> HTH
> Martin
> 
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]]
> Im Auftrag von Dias Marios
> Gesendet: Freitag, 3. Juli 2009 08:02
> An: [email protected]
> Betreff: st: no observations R 2000 error
> 
> Hi
> 
> I know this type of error has been posted before but i have
> followed some
> suggested solutions and i still cannot find a way to solve
> it.
> 
> THIS IS MY LIST OF VARIABLES
> 
> target_name       
>    str34        %34s
> company_id           
> byte        %8.0g
> market_return     
>    float        %9.0g
> ret               
>    float        %9.0g
> date               
>   float        %td
> event_date           
> float        %td
> datenum           
>    float        %9.0g
> td               
>     float        %9.0g
> dif               
>    float        %9.0g
> event_window          float 
>       %9.0g
> count_event_obs       float 
>       %9.0g
> estimation_window     float 
>       %9.0g
> 
> AND HERE IS THE CODE I AM TRYING TO RUN AND GET THE ERROR
> 
> set more off 
> 
> gen predicted_return=.
> egen id=group(company_id) 
> forvalues i=1(1)85 { 
>     l id company_id if id==`i' & dif==0
>     reg ret market_return if id==`i' &
> estimation_window==1 
>     predict p if id==`i'
>     replace predicted_return = p if id==`i'
> & event_window==1 
>     drop p
> }  
> 
> 
> I have checked that in my variables all missing values are
> replaced with a "
> . " so i would  guess that is not the problem.
> 
> Thanks
> 
> Marios
> 
> 
> 
>       
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index