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: incorrect results seen when creating new variable by multiplying existing variables


From   Mariano Matias Iberico <[email protected]>
To   <[email protected]>
Subject   st: incorrect results seen when creating new variable by multiplying existing variables
Date   Tue, 08 Mar 2011 23:17:15 -0500

I have a problem when trying to generate a new master variable to identify
clusters for an -expand– I use later.
When passing into 1000s of observations the newid variable becomes funky.

I managed to recreate the problem using a stata dataset:

.  sysuse nlsw88.dta
.  keep idcode age grade
.  replace grade=1 if grade==.
.  generate newid=.
.  format %11.0g newid
.  replace newid=_n*10000+age*100+grade

The problem is evident if you look at observation 2236 for example.

Newid    idcode age grade
22364108 5127   41  7

The grade portion of the newid does not parse with the actual grade
variable.
When using:
.  display 2236*10000+41*100+7
The result is fine!

This same problem occurs with observations 2238, 2241 and many others.

I can't figure out why this is occurring!

Regards,

Matias Iberico
MD/MPH candidate
Wright State University BSOM


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