Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Using "stata" command from Mata |

Date |
Tue, 23 Oct 2012 10:26:30 +0100 |

I suspect something about your quotation marks is biting. From your example filename, it seems that you don't have spaces in your filename, in general a very good idea, in which case I guess you don't need the internal "" and given that you don't need the outermost `" "' -- so the string is much simplified. string scalar temp temp = "imp excel " + this.path + this.workbook + ".xlsx" temp stata(temp) That said, I've never used the -import excel- command. Nick On Tue, Oct 23, 2012 at 10:15 AM, David Bell <d.n.f.bell@stir.ac.uk> wrote: > In Mata, I am writing a function to put together a string to supply to the "stata" command. It goes something like this: > void table::read_spreadsheet() > > { > string scalar temp > temp = "`" + `"""' + "imp excel " + `"""' + this.path + this.workbook + ".xlsx" + `"""' + `"""' + "'" > temp > stata(temp) > > } > > I suspect there are more efficient ways of constructing "temp", but I do know that executing "stata(temp)" in interactive mode works after I have constructed it as in the second line of my code. However, when I try to execute the function as part of a program, it seems to me that "temp" is abridged to 32 characters in the "stata" command after having been listed correctly in the previous line. i.e. my output from lines 3 and 4 is: > > > `"import excel "C:\Users\DavidNFBell\Dropbox\spreadsheet.xlsx""' - output of correctly formed string > unrecognized command: "import excel "C:\Users\DavidNFB invalid command name - error message indicating failure to execute stata(temp) command > stata(): 3598 Stata returned error > > I would be grateful if anyone could explain this/suggest an alternative > > David Bell > > -- > The University of Stirling is ranked in the top 50 in the world in The Times Higher Education 100 Under 50 table, which ranks the world's best 100 universities under 50 years old. > The University of Stirling is a charity registered in Scotland, > number SC 011159. > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: Using "stata" command from Mata***From:*David Bell <d.n.f.bell@stir.ac.uk>

**References**:**st: Using "stata" command from Mata***From:*David Bell <d.n.f.bell@stir.ac.uk>

- Prev by Date:
**st: Using "stata" command from Mata** - Next by Date:
**RE: st: Using "stata" command from Mata** - Previous by thread:
**st: Using "stata" command from Mata** - Next by thread:
**RE: st: Using "stata" command from Mata** - Index(es):