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

st: Re: a doubt about calculations in stata

From   "Martin Weiss" <>
To   <>
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:

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

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-

----- Original Message ----- From: "Rodrigo Briceño" <>
To: <>
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,
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
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
+506  22-91-12-00 ext. 113   Office
+506  22-32-08-30                Fax
+506  88-86-11-77                Cell

SKYPE: rbriceno1087

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index