Announcement

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

  • " is not a valid command name" r(199) error when trying to define and run a program

    I am trying to define a program that subsets data to loop over for some robustness analysis. For this, I try to add an option to choose a window option (e.g. 1yr or 2yr), but this causes the program to fail:


    Code:
    capture program drop subset_data
    program subset_data, sortpreserve
        syntax, ///
            window(string)
    end
    
    subset_data, ///
        window(1yr)
    Unfortunately, I keep getting this:


    Code:
    . capture program drop subset_judgeiv_data
    
    . program subset_judgeiv_data, sortpreserve
    1. syntax, ///
    > window(string)
    2. end
    
    .
    . // subset to IV analysis dataset
    . subset_judgeiv_data, ///
    > window(1yr)
    
    . ​
    ​ is not a valid command name
    r(199);
    
    end of do-file

    I thought this implied that I erroneously included a space that is being interpreted as a cmd somewhere but haven't been able to figure it out, making me suspect I do not correctly understand how to use string inputs in a program.
    Last edited by Joost Sijthoff; 08 Feb 2022, 10:24.

  • #2
    The continuation comment /// can't be used interactively but only in do-files and program files. Does that explain your problem?

    [U] 16.1.2

    The /* */, //, and /// comment indicators can be used in do-files and ado-files only; you may
    not use them interactively. You can, however, use the ‘*’ comment indicator interactively.

    Comment


    • #3
      Thanks for the help Nick!

      Unfortunately not, I am running it from the do-file editor and removing the / / / doesn't change the problem:


      Code:
      . do "C:\Users\JOOSTS~1\AppData\Local\Temp\STD1258_000000.tmp"
      
      . capture program drop subset_data
      
      . program subset_data, sortpreserve
        1.         syntax, window(string) 
        2. end
      
      . 
      . subset_data, window(1yr)
      
      . ​
      ​ is not a valid command name
      r(199);

      Comment


      • #4
        Check for non-printable characters with a good text editor or indeed hexdump.

        Comment


        • #5
          I didn't see anything odd viewing in VScode or
          Code:
          hexdump file, analyze
          You were probably right Nick. I retyped the program and now it does run.
          Apologies for the stupid problem and thanks for the help!

          Comment

          Working...
          X