Statalist


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

st: Re: a doubt about calculations in stata


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: Re: a doubt about calculations in stata
Date   Fri, 6 Mar 2009 22:42:41 +0100

<>

For anyone who wants to recreate Rodrigo`s prob:

*********
clear*
input double LOTE TIPO FOLIO VIV R101
1400 3 17162 9 18
1 0 1 0 1
end
gen id2=LOTE*1000000000+TIPO*100000000+FOLIO*1000+VIV*100+R101*1
format id2 %17.0g
l
*********

You have to do the calculations in the spreadsheet software yourselves, naturally. I get the same discrepancy that Rodrigo observed, though. Must have something to do with -help data_types-

HTH
Martin
_______________________
----- Original Message ----- From: "Rodrigo Briceño" <[email protected]>
To: <[email protected]>
Sent: Friday, March 06, 2009 10:31 PM
Subject: st: a doubt about calculations in stata


Dear Statalisters. I'm using Stata 9 and I'm trying to generate a new
variable that will be used as an identification for further merging of
several databases.
The id will be based on the conjunction of 5 variables called: LOTE,
TIPO, FOLIO, VIV, R101.
The larger and the lower values for each of these variables are shown below:
1400, 3, 17162, 9, 18 and 1, 0, 1, 0, 1

From these values I build a formula, that applied in excel produced
the desired results:

gen id2=LOTE*1000000000+TIPO*100000000+FOLIO*1000+VIV*100+R101*1

in excel the results produced were:  1,400,317,162,918 for the case
with larger values and  1,000,001,001 for the case with lower values.
The thing is that when I applied the formula in Stata the results are
wrong. I thought that the error comes from the number of values shown
in stata, but after changing to format id %14.0f the results are still
wrong.
What I got for the case of minimum values is the following: 1,000,001,024

Does anybody knows what is possibly causing this mistake? Thanks for
your kindly help.


--
Rodrigo Briceño
Economist
+506  22-91-12-00 ext. 113   Office
+506  22-32-08-30                Fax
+506  88-86-11-77                Cell
[email protected]
[email protected]

MSN: [email protected]
SKYPE: rbriceno1087

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


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index