Question

I'm trying to automate excel import into Stata. Here's my nonworking example. The error suggests to me that Stata is not evaluating the program argument as a scalar. How do I fix it?

scalar path = "C:\foo\data\"
scalar filename = "CompanyScores.xls"
scalar xlrange = "B3:AO149"
scalar sheet = "2012-2013 Scores"
scalar fullpath = path+"/"+filename
import excel fullpath, sheet(sheet) cellrange(xlrange) firstrow
Was it helpful?

Solution

You can fix this with:

import excel "`=fullpath'", sheet("`=sheet'") cellrange("`=xlrange'") firstrow

I also think you don't need the front slash the fullpath definition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top