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: Errors, lack if precision in carrying out operations for some observations


From   "Jan Keil" <[email protected]>
To   <[email protected]>
Subject   st: Errors, lack if precision in carrying out operations for some observations
Date   Sun, 15 May 2011 10:54:59 -0400

Dear Statalist,

I have the following problem:

Stata/SE 10.1 (Mac) does not undertake a simple operation on all of the 500,000 observations in my file (or does it with errors or not in a precise way).

I have 2 numeric variables, "gvkey" and "sid" (among others in the file) that are used to create a third, "id".

The commands are:

gen id = .
format id sid gvkey %16.2f
replace id = gvkey*1000 + sid


The result is that for some observations/rows the "id" variable is not calculated in a correct way.
Two examples are:

          id     gvkey    sid
 31567000.00  31567.00   1.00
119653096.00 119653.00  99.00

The values for "id" should be instead:

          id     gvkey   sid
 31567001.00  31567.00  1.00
119653099.00 119653.00 99.00


I tried different formats of the variables, I modified my command (calculated "id" with 2 steps), tried Stata 9, 10 and 11 (Mac and Windows).
I calculated a different "id" (my goal is to create a unique identifier) where I said "gen id = gvkey + sid/100" and Stata did not do it correctly to all observations. 
I also did that transformation in Excel and imported the resulting data as a csv file. "id" is calculated correctly in Excel, but when I import it to Stata it is not

Why is this happening?
What is the solution?

Thanks a lot in advance!
Jan


*
*   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