Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: RE: comas in numbrers
"Nick Cox" <email@example.com>
RE: st: RE: comas in numbrers
Mon, 3 May 2010 16:46:05 +0100
The problem has now been solved, but I can think of an explanation for Victor's problem with -sed-, namely that there is no such beast on his machine.
This would probably be the case if he is running Windows. -sed- is in origin a Unix utility. Various Windows ports exist but they must be deliberately installed to work! (As Steve pointed out, -sed- is _available_ for Windows.)
An experiment indicates that running the command on Windows through ! results in a empty but existent file2.txt even though no -sed- exists on the user's machine. Evidently the Windows shell is smart enough to initialise a file2.txt but then as sed doesn't exist nothing is put in it.
assume that your commas are not separating the integer from the
non-integer part of the numbers, but instead are indicating
thousands--see Jose's post today.
I suggest that you use -filefilter- instead of -sed- , Since this is
a Stata command, it will be platform independent, whereas the -sed-
command on your system might have a different syntax than the one on
mine (OS X 10.5.8, bash shell) . (The "-e" might be an issue; you
could omit it.) Either one of these two statements should work.
filefilter file1.txt file2.txt, from(",") to("") //best
filefilter file1.txt file2.txt, from(\044d) to("")
Monitor what is in file2.txt either by opening it up in your text
editor (best), or using -type-.
I'm not sure what you mean by "highlighting" the data, and I'm not
sure that I consider the do file editor as a good text editor. (I
wouldn't want to use it with a thousand-line file). Still, while you
are there (or in a good text editor), why not search for and replace
the comma, save out, as Jose and Nick suggested.
On Sun, May 2, 2010 at 12:20 PM, firstname.lastname@example.org <email@example.com> wrote:
> Thanks Steve ,however I seem to be doing something wrong with processing
> the following data into a file calling it file1.txt. I am doing this by
> highlighting the data,copy it and paste it into a do-file and then
> saving it as file1.txt. .....
> 31,666 15,127 46,793 31,259 15,409 46,668 30,215 17,182 7,397
> 28,323 13,798 42,121 28,267 14,024 42,291 27,049 15,886 2,935
> 6,615 2,307 8,922 6,668 2,602 9,270 6,130 3,380 9,510
> 7,829 4,196 12,025 7,556 3,855 11,411 7,020 4,336 11,356
> 5,583 2,809 8,392 6,098 2,856 8,954 6,177 3,145 9,322
> 4,399 2,421 6,820 4,311 2,520 6,831 4,119 2,609 6,728
> 3,897 2,065 5,962 3,634 2,191 5,825 3,603 2,416 6,019
> 3,343 1,329 4,672 2,992 1,385 4,377 3,166 1,296 4,462
> do "C:\DOCUME~1\Victor\LOCALS~1\Temp\STD04000000.tmp"
> capture erase file2.txt
> ! sed -e 's/,//g' file1.txt>file2.txt
> infile v1 v2 v3 using file2.txt, clear
> (0 observations read)
> Contains data
> obs: 0
> vars: 0
> size: 0 (100.0% of memory free)
> Sorted by:
> end of do-file
> On 28/4/2010, "Steve Samuels" <firstname.lastname@example.org> wrote:
>>Victor, you can skip all the problems of adding quotes or destringing
>>by deleting the commas outside of Stata. Use the SED package, built
>>into all the Unix, Linux, and OS X distributions and also available
>>for Windows. Write the data into a text file, say file1.txt. Here is
>> File file1.txt contains the following two lines with three variables
>>3,000,000 4,000,000 .
>> 40,000 300,000 100
>>capture erase file2.txt
>>! sed -e 's/,//g' file1.txt>file2.txt
>>infile v1 v2 v3 using file2.txt, clear
* For searches and help try: