Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Stata 12 issues with .csv files

From   Nick Cox <>
Subject   Re: st: Stata 12 issues with .csv files
Date   Thu, 3 Jan 2013 03:24:08 +0000

You say that -recast- doesn't work but don't explain what means
precisely. One reason for -recast- not working as you hope with the
-homestead- variable could be that the variable is string.  -recast-
wouldn't cross the string-numeric boundary.

I don't think Stata's behaviour on this point varies as between 32 and
64 bit or 11.2 and 12.

If you don't get a better answer, I think it's a case of Stata tech
support seeing some of these files, unless you can post them somewhere
where others can have look.


On Wed, Jan 2, 2013 at 8:49 PM, Daniel MacPherson
<> wrote:

> I'm having issues with .csv files (Excel 32-bit) and Stata 12 64-bit.
> I'm trying to append a large number of .csv files together. The append
> command works with most of the files, but occasionally one of these
> .csv files causes to Stata to crash and shut down immediately. I've
> been able to isolate both the problematic files and the bad variables
> within these files. They don't appear to be any different in format
> than variables in non-problematic files. I've tried recasting the
> variables into a set format before appending them but this hasn't
> worked either. When I run the code on Stata 11.2 32-bit, I don't
> encounter the problem. Any help would be appreciated. Thanks.
> Below is the code I'm using:
> clear all
> set more off
> cd C:\Users\macpherd\nal_project\
> file open cd using c:\USERS\macpherd\nal_project\cd.txt, read
> file read cd line
> while r(eof)==0 {
> cd `line'
> local i=0
> local round=substr("`line'",31,4)
> cap erase Exmpt_`round'.dta
> local files: dir . files "*.csv"
> foreach f of local files {
> drop _all
> insheet using "`f'"
> format mpid %9s
> recast long homestead, force *** Doesn't work!!!***
> keep mpid co_no land_use_code exempt_other homestead widow disable rnwl_energy
> local y "land_use_code exempt_other homestead widow disable rnwl_energy"
> foreach y of varlist `y' {
> rename `y' `y'_`round'
> }
> if `i'>0 append using Exmpt_`round'
> save Exmpt_`round', replace
> local i=1
> }
> drop _all
> file read cd line
> }
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index