Announcement

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

  • Conformability error, r(503)

    Hi everyone, I have a problem when I want to input a matrix in Stata. First I local some results and then I want to construct my matrix but Stata show me r(503). Any help would be appreciated, thanks. In the figure you can see the command that I used.

    Click image for larger version

Name:	jkl.PNG
Views:	2
Size:	20.5 KB
ID:	1496967

  • #2
    Your problem is that you have named your two final locals
    Code:
    glevel14
    glevel15
    which are not the names you use in your matrix input command.

    Comment


    • #3
      I can't replicate your problem:

      Code:
      . webuse nlswork, clear
      (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
      
      . 
      . levelsof ln_wage if idcode == 1 & year == 70, local(glevel1)
      1.451213955879211
      
      . levelsof ln_wage if idcode == 1 & year == 71, local(glevel2)
      1.028619766235352
      
      . levelsof ln_wage if idcode == 1 & year == 72, local(glevel3)
      1.589977383613586
      
      . levelsof ln_wage if idcode == 1 & year == 73, local(glevel4)
      1.780272841453552
      
      . levelsof ln_wage if idcode == 1 & year == 75, local(glevel5)
      1.777011632919312
      
      . 
      . matrix input LEVEL = (`glevel1' \ `glevel2' \ `glevel3' \ `glevel4' \ `glevel5')
      
      . matrix list LEVEL
      
      LEVEL[5,1]
                 c1
      r1   1.451214
      r2  1.0286198
      r3  1.5899774
      r4  1.7802728
      r5  1.7770116
      
      . 
      end of do-file
      That said, I wouldn't use this approach. If there is no observation with a particular combination of wavenum and country, the corresponding local macro will be undefined, not missing value. Moreover, if there are multiple observations with the same combination of wavenum and country but different values of glevel, you will definitely get (and deserve) a non-conformability error. I would do this as:

      Code:
      summ glevel if wavenum == 1 & country == 112
      assert r(min) == r(max) & r(N) > 0
      local glevel1 `r(min)'
      
      // ETC.
      This way the code will break and tell you of the problem more clearly if there is an -if- condition with no satisfiers or if there is an if condition that yields more than 1 value of glevel.

      But it is clear from your output that these are not the problems you are having. I really don't know what to suggest, as the same code works fine for me on Stata 15.1 MP2, Windows 7.

      Comment

      Working...
      X