Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Using "stata" command from Mata
From
David Bell <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: Using "stata" command from Mata
Date
Tue, 23 Oct 2012 10:15:22 +0100
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/