Statalist


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

Re: st: -merge- in version11 fails to sort automatically


From   Padmakumar Sivadasan <[email protected]>
To   [email protected]
Subject   Re: st: -merge- in version11 fails to sort automatically
Date   Mon, 7 Dec 2009 14:09:35 -0600

Thanks Martin.

I shall get in touch with State Tech Support and update when I hear from them.

Padmakumar

On Mon, Dec 7, 2009 at 11:38 AM, Martin Weiss <[email protected]> wrote:
>
> <>
>
>
> Ok, so the error actually happens while -_merge- is active, and this is a
> "built-in" command, so only Stata Tech Support can help you with this
> problem.
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Padmakumar
> Sivadasan
> Gesendet: Montag, 7. Dezember 2009 18:33
> An: [email protected]
> Betreff: Re: st: -merge- in version11 fails to sort automatically
>
> Thank you Martin and Bill for your prompt reply !
>
> As Martin suggested, I am including below the output when I run the
> -merge- with -set trace on-. Since I don't find an error notification
> at  -checksort- I have included the entire output from the beginning
> of the -merge- command till the error message.
>
> As Bill suggested, I shall also send my data and log files to Stata
> technical support.
>
> Thanks
>
> Padmakumar
>
> . set trace on
>
> . merge 1:1 cik fyear using compustatcsaall
> ----------------------------------------------------------------------------
> ------------------------------------------------------
> begin merge ---
> - version 11
> - gettoken mtype 0 : 0, parse(" ,")
> - if (!strpos("`mtype'", ":") & "`mtype'"!="") {
> = if (!strpos("1:1", ":") & "1:1"!="") {
>  if (_caller()>=11) {
>  di as smcl as txt "{p}"
>  di as smcl "(note: you are using old"
>  di as smcl "{bf:merge} syntax; see"
>  di as smcl "{bf:{help merge:[R] merge}} for new syntax)"
>  di as smcl "{p_end}"
>  }
>  merge_10 `mtype' `0'
>  exit
>  }
> - local origmtype `"`mtype'"'
> = local origmtype `"1:1"'
> - mata: map_mtype(`"mtype"')
> - gettoken token : 0, parse(" ,")
> - if ("`token'"=="_n") {
> = if ("cik"=="_n") {
>  if ("`mtype'"!="1:1") {
>  error_seq_not11 "`mtype'" "`origmtype'"
>  }
>  gettoken token 0 : 0, parse(" ,")
>  local mtype "_n"
>  }
> - syntax [varlist(default=none)] using/ [, ASSERT(string) DEBUG
> GENerate(name) FORCE KEEP(string) KEEPUSing(string) noLabel NOGENerate
> noNOTEs REP
>> LACE noREPort SORTED UPDATE ]
> - if ("`mtype'"!="_n") {
> = if ("1:1"!="_n") {
> - local origmtype `"`mtype'"'
> = local origmtype `"1:1"'
> - mata: map_mtype(`"mtype"')
> - if ("`varlist'"=="") {
> = if ("cik fyear"=="") {
>  error_mat_varlist "`mtype'" "`origmtype'"
>  }
> - }
> - else {
>  if ("`mtype'"=="_n") {
>  if ("`varlist'"!="") {
>  error_seq_varlist
>  }
>  }
>  }
> - mata: fullfilename("using", "usingfull", "using")
> - mata: resultlist("assert")
> - mata: resultlist("keep")
> - if ("`generate'"!="") {
> = if (""!="") {
>  if ("`nogenerate'"!="") {
>  di as smcl err "{p}"
>  di as smcl "options -generate()- and -nogenerate-"
>  di as smcl "may not be specified together."
>  di as smcl err "{p_end}"
>  }
>  confirm new var `generate'
>  }
> - if ("`replace'"!="") {
> = if (""!="") {
>  if ("`update'"=="") {
>  error_replace
>  }
>  }
> - if ("`sorted'"=="" & "`mtype'"!="_n") {
> = if (""=="" & "1:1"!="_n") {
> - local sortedby : sortedby
> - checksort "`sortedby'" "`varlist'"
> = checksort "company_fkey begin_year file_date" "cik fyear"
>
> ----------------------------------------------------------------------------
> ------------------------------------------
> begin merge.checksort ---
>  - args is should
>  - local i 0
>  - foreach v1 of local should {
>  - local ++i
>  - local v2 : word `i' of `is'
>  = local v2 : word 1 of company_fkey begin_year file_date
>  - if ("`v1'"!="`v2'") {
>  = if ("cik"!="company_fkey") {
>  - return scalar sorted = 0
>  - exit
>  - local ++i
>  - local v2 : word `i' of `is'
>  = local v2 : word 2 of company_fkey begin_year file_date
>  - if ("`v1'"!="`v2'") {
>  = if ("fyear"!="begin_year") {
>  - return scalar sorted = 0
>  - exit
>
> ----------------------------------------------------------------------------
> --------------------------------------------
> end merge.checksort ---
> - if (!r(sorted)) {
> - sort `varlist'
> = sort cik fyear
> - }
> - quietly describe using "`using'", varlist short
> = quietly describe using "compustatcsaall.dta", varlist short
>
> ----------------------------------------------------------------------------
> -------------------------------------------------
> begin describe ---
>  - version 9
>  - local version : di "version " string(_caller()) ":"
>  - syntax [anything] [using] [, SImple *]
>  - local varlist `"`anything'"'
>  = local varlist `""'
>  - if ("`simple'" == "") {
>  = if ("" == "") {
>  - `version' _describe `0'
>  = version 11: _describe using "compustatcsaall.dta", varlist short
>  - return add
>  - }
>  - else {
>    if (`"`options'"' != "") {
>    di as err "simple may not be combined with other options"
>    exit 198
>    }
>    if (`"`using'"' != "") {
>    qui `version' describe `varlist' `using', varlist
>    if "`varlist'" == "" {
>    local vars "`r(varlist)'"
>    }
>    else {
>    local vars "`varlist'"
>    }
>    local wid = 2
>    local n : list sizeof vars
>    if `n'==0 {
>    exit
>    }
>    foreach x of local vars {
>    local wid = max(`wid', length(`"`x'"'))
>    }
>    local wid = `wid' + 2
>    local cols = int((`c(linesize)'+1)/`wid')
>    if `cols' < 2 {
>    foreach x of local `vars' {
>    di as txt `col' `"`x'"'
>    }
>    exit
>    }
>    local lines = `n'/`cols'
>    local lines = int(cond(`lines'>int(`lines'), `lines'+1, `lines'))
>    forvalues i=1(1)`lines' {
>    local top = min((`cols')*`lines'+`i', `n')
>    local col = 1
>    forvalues j=`i'(`lines')`top' {
>    local x : word `j' of `vars'
>    di as txt _column(`col') "`x'" _c
>    local col = `col' + `wid'
>    }
>    di as txt
>    }
>    qui `version' describe `varlist' `using', short
>    return add
>    }
>    else {
>    ds `varlist'
>    qui `version' _describe `varlist', short
>    return add
>    }
>    }
>
> ----------------------------------------------------------------------------
> ---------------------------------------------------
> end describe ---
> - local sortedby "`r(sortlist)'"
> = local sortedby "gvkey fyear"
> - checksort "`sortedby'" "`varlist'"
> = checksort "gvkey fyear" "cik fyear"
>
> ----------------------------------------------------------------------------
> ------------------------------------------
> begin merge.checksort ---
>  - args is should
>  - local i 0
>  - foreach v1 of local should {
>  - local ++i
>  - local v2 : word `i' of `is'
>  = local v2 : word 1 of gvkey fyear
>  - if ("`v1'"!="`v2'") {
>  = if ("cik"!="gvkey") {
>  - return scalar sorted = 0
>  - exit
>  - local ++i
>  - local v2 : word `i' of `is'
>  = local v2 : word 2 of gvkey fyear
>  - if ("`v1'"!="`v2'") {
>  = if ("fyear"!="fyear") {
>    return scalar sorted = 0
>    exit
>    }
>  - }
>  - return scalar sorted = 1
>
> ----------------------------------------------------------------------------
> --------------------------------------------
> end merge.checksort ---
> - if (!r(sorted)) {
>  preserve
>  qui use "`using'", clear
>  sort `varlist'
>  tempfile using
>  qui save "`using'", replace
>  restore
>  }
> - }
> - if ("`nogenerate'"!="") {
> = if (""!="") {
>  tempvar mergevar
>  local mergevaristemp 1
>  }
> - else {
> - local mergevar = cond("`generate'"!="", "`generate'", "_merge")
> = local mergevar = cond(""!="", "", "_merge")
> - local mergevaristemp 0
> - }
> - local options `update' `replace' `notes' `label' _merge(`mergevar')
> `force'
> = local options     _merge(_merge)
> - if (substr("`mtype'", 1, 1)=="1") {
> = if (substr("1:1", 1, 1)=="1") {
> - local options `options' uniqmaster
> = local options _merge(_merge) uniqmaster
> - }
> - if (substr("`mtype'", 3, 1)=="1") {
> = if (substr("1:1", 3, 1)=="1") {
> - local options `options' uniqusing
> = local options _merge(_merge) uniqmaster uniqusing
> - }
> - if ("`keepusing'"!="") {
> = if (""!="") {
>  local options `options' keep(`keepusing')
>  }
> - if ("`keep'" !="" & !strpos("`keep'" , "2")) { local options `options'
> nokeep
> = if ("" !="" & !strpos("" , "2")) { local options _merge(_merge)
> uniqmaster uniqusing nokeep
>  }
> - local _merge `"_merge `varlist' using "`using'", nowarn `options'"'
> = local _merge `"_merge cik fyear using "compustatcsaall.dta", nowarn
> _merge(_merge) uniqmaster uniqusing"'
> - if ("`debug'"!="") {
> = if (""!="") {
>  di as txt _n "command is"
>  di `"`_merge'"' _n
>  }
> - `_merge'
> = _merge cik fyear using "compustatcsaall.dta", nowarn _merge(_merge)
> uniqmaster uniqusing
> using data not sorted
> ----------------------------------------------------------------------------
> --------------------------------------------------------
> end merge ---
> r(5);
>
>
>
> On Mon, Dec 7, 2009 at 10:43 AM, William Gould, StataCorp LP
> <[email protected]> wrote:
>> Padmakumar Sivadasan <[email protected]> is using Stata 11
>> and reports obtaining the following output,
>>
>>        . merge 1:1 cik fyear using compustat
>>        using data not sorted
>>        r(5);
>>
>> even though the manual states that you are not required to have the
>> datasets sorted before using -merge-.
>>
>> Martin Weiss <[email protected]> helpfully wrote,
>>
>>> -merge 1:1- performs its -checksort- as one of its first tasks. So
>>> -set trace on- and report what happens there...
>>
>> Padmakumar can do that and then we can see if we can determine the source
>> of the problem here on the list, but I recommend that Padmakumar go to
>> Stata technical support with this problem.
>>
>> I have tried to reproduce this problem, and I cannot.
>>
>> The first request Technical Services will make is that Padmakumar send
>> a log and a copy of the data so we can reproduce the problem here.
>>
>> -- Bill
>> [email protected]
>> *
>> *   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/
>

*
*   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