| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: -odbc-, Excel cell range
I am trying to read data from an Excel (work)sheet into Stata, using -odbc-.
This works:
odbc load, dsn("Excel Files;DBQ=test.xls") exec("SELECT * from [s1$]")
The file "test.xls" is from here:
http://www.ats.ucla.edu/stat/stata/faq/test.xls, and looks like this:
. list
+--------+
| a b |
|--------|
1. | 2 5 |
2. | 3 6 |
3. | 4 8 |
4. | 5 9 |
5. | 76 0 |
+--------+
I would like to define a certain cell-range in the Excel worksheet from
which the data are read into Stata. Let's say I want to choose only the
bottom row, so that the data would look like this:
+--------+
| a b |
|--------|
1. | 76 0 |
+--------+
I thought that this code would get me there:
odbc load, dsn("Excel Files;DBQ=test.xls") exec("SELECT * from [s1$a6:b6]")
However, what I get is this:
. list
+---+
| b |
|---|
1. | 5 |
2. | 6 |
3. | 8 |
4. | 9 |
5. | 0 |
+---+
So, my question is: using -odbc-, how can I select a cell-range inside a
worksheet of an Excel file?
Thanks,
Philipp
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/