| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
-- Re: st: Writing out Names with special signs or words -- Can't write
From |
Nick Winter <[email protected]> |
To |
[email protected] |
Subject |
-- Re: st: Writing out Names with special signs or words -- Can't write |
Date |
Fri, 17 Mar 2006 12:18:07 -0500 |
You need to use compound double quotation marks to wrap up the strings--
that is, `" before and "' after.
. gen x = `"abc " def"'
This will deal with strings that have quotation marks (") in them.
. gen y = `"abc ` def"'
too few quotes
r(132);
However, this will not work for strings that have an open-single-quote (`)
in them. Wrapping *those* strings in regular double quotes works.
. gen y = "abc ` def"
Any ideas on the list on how to deal with both?
If you are reading these from a text file, you might use -filefilter- to
change all the single open quotes (`) to some other character combination,
read in the lines, then change them back. Something like:
. filefilter inputfile tempfile , from("\LQ") to("[opensinglequote]")
...do input using tempfile...
. replace x = subinstr(x,"[opensinglequote]","`",.)
At 11:21 AM 3/17/2006, you wrote:
Dear Austin,
Thanks for sending me the example. Unfortunately, I can replicate the results.
I write down a small DO file, writing all 33 examples of names as in my
first posting,
but the program starts to have error messeages. For example:
(1) Example 1
gen x30= ""CDC POINT - S.P.A. (ANCHE IN FORM";
-- error message is: . gen x30= ""CDC POINT - S.P.A. (ANCHE IN FORM"
invalid 'POINT'
r(198);
(2) Example 2:
. gen x34= "Weird Combination (quotes "-and hyphen' a]pos`trophe 1-d_5."
and not found
r(111);
Writing out to text file:
file open wot2 using L:\wtest3.txt, write append
. file write wot2 _n "`x[1]'"
. file write wot2 _n "` x[2] '"
And the text file only show blanks lines !!
I have more than one million names to do, so it is almost impossible to
search for weird
combinations of signs manually.
Similarly, the same problems also exist when I "chop" the names into parts
and compare
those parts to other names' part.
But many thanks for your example code.
Akihito
----------------------
From: "Austin Nichols" <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: st: Writing out Names with special signs or words
Date: Thu, 16 Mar 2006 16:13:32 -0500
There's no reason you shouldn't be able to write out the strings you
have shown, but it's possible that by pasting the strings into email,
you have stripped out some problematic characters.
____________________
set obs 1
gen x="`IPAD AD DOBOJ"
file open f using /f.txt, write replace
file write f _n "`=x[1]'"
file close _all
type /f.txt
`IPAD AD DOBOJ
____________________
works, so the string as shown is fine. Do you need the special
characters in the names--they are not readable as is, anyway, right?
Unless you specify a Bosnian font for only the Bosnian names, which is
not possible for most applications. If you don't need them, see
-findit charlist- for a way to identify them and then zap them with
(for example) the subinstr() function.
*
* 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/
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
*
* 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/
--------------------------------------------------------
Nicholas Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government [email protected] e
308 White Hall falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-4601
*
* 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/