Benjamin Allaire wrote:
I had a quick question, I'm trying to import a dataset into intercooled
stata and it contains too many variables, so I was trying to insheet the
variables I need. It's a csv file and I tried the following command:
insheet district month year using cfy06e3.csv, c names clear
And got the following error:
too few variables specified
error in line 3934 of file
r(102);
which is odd considering there are only 3932 observations and I don't
particularly expect to get an error like this with the insheet command.
Does anyone have any good ideas on a work around?
--------------------------------------------------------------------------------
It's not clear from your post what platform you're using, but if it's
Windows, then you might be able to use -odbc- with Microsoft's ODBC text
driver to do what you want, i.e., read in a subset of the variables from a
comma-separated-value text file. There might be other, better avenues
suggested by others on the list, but this is the one that surfaces to me
first for your situation. (Also consider upgrading.)
Joseph Coveney
* Creating test data file
clear
set more off
set obs 3932
forvalues i = 1/320 { // Any arbitrarily large number
quietly generate byte var`i' = 1
}
outsheet using dummy.csv, names comma replace
*
* Begin here
*
odbc query "Microsoft Text Driver"
odbc describe dummy.csv
odbc load var1 var2, table(dummy.csv) clear
erase dummy.csv
exit
*
* 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/