TiesdeKok / ipystata

Enables the use of Stata together with Python via Jupyter (IPython) notebooks.
192 stars 68 forks source link

Python doesn't recognize Stata type comments #9

Closed danielkdimitrov closed 7 years ago

danielkdimitrov commented 8 years ago

Hello, I'm running some stata code in iPython Notebook using the ipystata plug-in. Everything runs fine, but whenever i have a comment in the Stata code it doesn't get recognized and the code fails.

For example if I use // to put coments, the code fails with 'unrecognized command: / invalid command name'. for example in the following like

gen i = _n // included additional to generate an index for the individual level

The same happens when I use * or ## or ^^ as well.

So my question is, how can I write comments in the cells where I run stata code?

I am using Windows, Stata 13 MP. It seems that my friend who is working on Mac doesn't have this problem.

TiesdeKok commented 8 years ago

Hi,

That is true, the reason is that Stata automation executes the code in the command box of Stata, not via the do-file.

The problem is the following: (See here Stata Technical note):

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.

This is unfortunately beyond my control, you can still use a * to comment out lines.

The Mac and Linux version ('Stata Batch mode') use a simplified version that uses .do files, which does support all comment methods.

danielkdimitrov commented 8 years ago

Thanks, this helps. I now leave comments in a new line rather on the same line that contains valid code, and * separation works fine

TiesdeKok commented 7 years ago

Thanks @pacbard for helping deal with this problem. Commenting should work fine now.