Announcement

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

  • Question/Help: Inconsistent Invalid Name Error? (r(198))

    Hi, this simple command is inconsistent each time I open my data set - please help me understand why.

    drop if TNM_CLIN_T=="c1"&TNM_CLIN_N=="c0"
    (807 observations deleted)

    drop if TNM_CLIN_T==“c2”&TNM_CLIN_N==“c0”
    “c2” invalid name
    r(198);

    browse TNM_CLIN_T <--- checking to make sure there are c2 values

    drop if TNM_CLIN_T=="c2"
    (3,734 observations deleted)


    So essentially every time:
    drop if VARIABLE=="a1" & VARIABLE2 == "a2"

    - This command works just fine, but then I also want to drop on another condition with those variables:

    drop if VARIABLE=="b1" & VARIABLE2 == "b2"
    "b1" invalid name r(198)
    - b1 is definitely there, no issues with the value, it's a string, double-checked on everything.

    But if I do only
    drop if VARIABLE == "b1"
    on some runs it tells me it's invalid, and on some it works.


    I am not doing anything else with this data set besides closing out and starting from scratch with these commands to try to specifically source where the issue is.
    No success.
    What could I be doing wrong? Why is it not finding the value seemingly inconsistently?






  • #2
    In your posting here, your second command has "smart quotes" in it, as though you typed some syntax in MS Word.
    drop if TNM_CLIN_T==“c2”&TNM_CLIN_N==“c0”
    If you did use those in your actual syntax, try changing them to "regular" quotes.
    Last edited by Mike Lacy; 18 Jun 2021, 10:18.

    Comment


    • #3
      Your double quotes appear to be the problem. If I copy them exactly from your post

      drop if TNM_CLIN_T==“c2”&TNM_CLIN_N==“c0”
      I can replicate your error.

      Code:
      sysuse auto, clear
      drop if regexm(make, Toyoya)
      *OK
      drop if regexm(make, "Toyota")
      Res.:

      Code:
      . sysuse auto, clear
      (1978 Automobile Data)
      
      .
      . drop if regexm(make, “Toyoya”)
      “Toyoya” invalid name
      r(198);
      
      .
      . *OK
      
      .
      . drop if regexm(make, "Toyota")
      (3 observations deleted)
      Crossed with #2.

      Comment


      • #4
        Jeez - such an easy fix - I wasn't even noticing the quotations. Thank you so much.

        Comment

        Working...
        X