Bookmark and Share

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


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

st: RE: comas in numbrers


From   Steve Samuels <[email protected]>
To   [email protected]
Subject   st: RE: comas in numbrers
Date   Tue, 27 Apr 2010 21:12:41 -0400

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
an example:

**************************CODE BEGINS**************************
/*
 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
des
list
***************************CODE ENDS**************************

Steve

On Tue, Apr 27, 2010 at 5:16 PM, Martin Weiss <[email protected]> wrote:
>
> <>
>
> To answer this conclusively, we need to know where the data reside, i.e.
> what kind of a file.
>
> I just created a file "Book1.txt" from spreadsheet software, containing
> numbers with commata in them, and used -insheet using Book1.txt, tab clear-
> to get them into Stata. "tab" is just a red herring here so Stata does not
> treat the commata as delimiters. Afterwards, I -destring-ed as described
> before and ended up with a numeric variable in Stata. This approach could be
> viable for you as well.
>
>
> HTH
> Martin
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of [email protected]
> Sent: Dienstag, 27. April 2010 19:54
> To: [email protected]
> Subject: st: RE: RE: RE: comas in numbrers
>
> I mean thousands of observations,represented by numbers with a coma in
> them.It is a problem because it would take too much time to quote
> unquote each one of them.
> Unfortunately,in Eurostat we come across commas in numbers.
>
>
>
> On 27/4/2010, "Martin Weiss" <[email protected]> wrote:
>
>>
>><>
>>
>>What do you mean? There is no substantive difference to the situation with
> 5
>>obs, is there? Apart from the fact that you do not want to -input- them
> all,
>>but that problem is unrelated to the issue of commata...
>>
>>
>>HTH
>>Martin
>>
>>
>>-----Original Message-----
>>From: [email protected]
>>[mailto:[email protected]] On Behalf Of [email protected]
>>Sent: Dienstag, 27. April 2010 19:16
>>To: [email protected]
>>Subject: st: RE: RE: comas in numbrers
>>
>>What do I do when there are thousands of observations?
>>
>>
>>
>>010, "Martin Weiss" <[email protected]> wrote:
>>
>>>
>>><>
>>>
>>>*************
>>>
>>> drop _all
>>>
>>>input str10 a
>>>"2,345"
>>>"213"
>>>"34,456"
>>>"458"
>>>end
>>>
>>>destring a, generate(numerica) ignore(,)
>>>l
>>>*************
>>>
>>>
>>>HTH
>>>Martin
>>>
>>>-----Original Message-----
>>>From: [email protected]
>>>[mailto:[email protected]] On Behalf Of [email protected]
>>>Sent: Dienstag, 27. April 2010 17:39
>>>To: [email protected]
>>>Subject: st: RE: comas in numbrers
>>>
>>>Dear Statalist,
>>>
>>>how do you handle numbers with a coma to indicate thousands?
>>>I thank you before hand
>>>Victor M. Zammit
>>>
>>> drop _all
>>>
>>> input a
>>>
>>>a
>>>1. 2,345
>>>2. 213
>>>3. 34,456
>>>4. 458
>>>5. end
>>>
>>>..
>>>end of do-file
>>>
>>> l
>>>
>>>+-----+
>>>a
>>>-----
>>>1.    2
>>>2.  213
>>>3.   34
>>>4.  458
>>>+-----+
>>>


-- 
Steven Samuels
[email protected]
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fax:    206-202-4783



-- 
Steven Samuels
[email protected]
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fax:    206-202-4783
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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