Announcement

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

  • Problem with program (error 198)

    I'm new to mata and have a syntax problem I can't seem to solve. I got a program for testing for stochastic dominance and when I try to run this I get a syntax (198) problem which says ( `min' invalid name) so it's related to how the min is specified. Here is the portion that I think contains the error. Something I noticed is that it was meant for stata 6 but I'm using stata 12 and I've changed the version name at the top but haven't changed anything else.

    #delimit ;
    program define dom; * syntax is dom var1 wgt1 var2 wgt2 zmax #test-points;
    version 6.0;
    local x1 `1';
    local wgt1 `2';
    local x2 `3';
    local wgt2 `4';
    local zmax = `5';
    local num = `6';
    summarize `x1', meanonly;
    local min1 = r(min);
    summarize `x2', meanonly;
    local min2 = r(min);
    local min = max(`min1',`min2');
    local inter = (`zmax'-`min')/(`num'-1);
    local min = `min’ + `inter’; * Don’t start at very end of tail;
    local inter = (`zmax'-`min')/(`num'-1);
    local done = 0;
    local s = 1;
    tempvar ind;
    display " ";
    display "Minimum test point is " `min';
    display " ";
    display "Maximum test point is " `zmax';
    display " "; if `zmax' <= `min' {;
    local done = 1;
    display " ";
    display in red "Error: " in yellow "Max test point is not larger than
    min test point!";
    display " ";
    };
    while `done' == 0 {;
    display " ";
    display "Order " `s';
    display "Z D1 D2 t-statistic";
    local alpha = `s' - 1;
    local i = 1;
    local z = `min';
    quietly gen `ind' = .;
    while `z' <= `zmax' {;

    Sorry if this is too much but I've only started using mata today and amn't sure exactly where the problem is.

  • #2
    1) Your code has nothing to do with mata. There was no mata in Stata6, so if you just copied it from there, make sure you are running it in Stata mode.
    2) The code could be simplified by employing the many new features added to Stata after release 6;
    3) The code of course should continue to run under version control.
    4) The problem you experience is because someone was editing the code since it was last tested and used the wrong quotes:
    Click image for larger version

Name:	quotes.png
Views:	2
Size:	9.7 KB
ID:	102897
    5) Note that modern Stata has syntax highlighting. If it is not highlighting your locals, perhaps you are using the wrong quotes.
    Best, Sergiy Radyakin
    Attached Files
    Last edited by Sergiy Radyakin; 26 Jul 2014, 23:35.

    Comment


    • #3
      Thanks for your help. I have tried that and now stata returns a syntax problem without giving any clue about the problem. I realise this isn't mata now.

      Comment

      Working...
      X