Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Problem with embedded quotes in strings when using insheet


From   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   st: Re: Problem with embedded quotes in strings when using insheet
Date   Thu, 31 Mar 2005 07:18:54 -0800 (PST)

Dave,

One option is to save a second copy of your data in Stata format to
avoid the -insheet- step. Another option is to use Stat/Transfer in
combination with -stcmd- to convert data from Stata to Excel format
and back.

Friedrich

--- David E Moore <[email protected]> wrote:
> I didn't notice this little "undocumented feature" in the faq for
> reading Excel
> data, so I thought I'd see if anyone has a workaround.  Just so you
> know, I'm
> leaning toward -file- to "solve" the problem, but it's quite a lot
> more work
> than -insheet- ....
> 
> Here's the situation:
> 
> I write out a portion of the data currently held in memory,
> including some
> string variable values, using -outsheet-.  Some of the strings have
> double
> quotes (not always balanced) embedded in them.  (I know, I
> shouldn't have
> allowed this in the first place.)  When I -outsheet- the data it
> looks perfectly
> fine and I can read it into Excel just fine.  Now, I want to append
> more data to
> that file, so I -insheet- the original, append the new data, and
> -outsheet-
> again.  When I -insheet- the data, the embedded quotes confuse the
> heck out of
> the -insheet- parser and the data are no longer fine.  I can
> provide details on
> what happens, but that isn't really relevant.
> 
> I use "tab" as my delimiter when writing and reading the file, so
> I'm not
> exactly sure why Stata thinks it should be looking at quotes in the
> first place
> (hence, undocumented feature), but that's the way it is.
> 
> My question is:
> 
> Does anyone see or know a fairly efficient way around this problem
> (i.e., to
> read embedded quotes properly)?  Right now, I'm trying to read in
> each line of
> the tab delimited file and parse it myself.  That's okay, but it
> makes for some
> rather ugly programming and amounts to writing my own -insheet-
> command.
> 
> Thanks for any suggestions.
> 
> Dave


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index