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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: RE: Problems adding large numbers |

Date |
Wed, 28 Oct 2009 14:02:27 +0100 |

<> So Shruti should probably specify a safe -format- for -egen, concat()- because its default will lead him astray, just as he seemed to imply towards the end of his initial post... ************* clear* set obs 2 gen /*double */ HHID=16817000 gen PERNUM=4 replace PERNUM= 5 in 2 gen double x1=HHID+PERNUM gen x2=string(HHID)+string(PERNUM) egen x3=concat(HHID PERNUM) egen x4 = concat(HHID PERNUM), /* */ format("%15.0f") list, noo ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nick Cox Gesendet: Mittwoch, 28. Oktober 2009 13:50 An: statalist@hsphsun2.harvard.edu Betreff: st: RE: Problems adding large numbers As Martin Weiss has implied, this is a precision problem. It is aired monthly (if not weekly) on this list. You could tackle it by specifying storage type as in Martin's code. Alternatively, hold the identifiers as strings. You can combine by concatenation. -egen, concat()- will do that for you and handle any conversion issues. That practice is entirely consistent with identifiers having numeric characters as content, later extraction of substrings, etc. Nick n.j.cox@durham.ac.uk Shruti Kapoor i have a huge individual level dataset. I am trying to generate a new variable x which is the sum of my household id(HHID) and person number in each household (PERNUM) for some condition if it is true. The problem i am facing is that at very large values of HHID lets say 16817000, if the PERNUM is 4 and 5 if should generate variable x = 16817004 and 16817005. What stata is doing is rounding off the numbers so that i am getting the same values for both PERNUM 4 and 5. This is a problem because it is no longer creating a unique value of X which i need. I string to convert the two variables into string and then creating x = HHID + PERNUM, but now i am getting answers like 1.68e10+05. How can i resolve this issue such that it creates a unique value for each individual in the household and x stays numeric? * * 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/

**References**:**st: Problems adding large numbers***From:*Shruti Kapoor <kapoor@oxy.edu>

**st: RE: Problems adding large numbers***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: Can I produce a regression output with -outreg2- after -xtoverid2, noisily- ? and temporary names query.** - Next by Date:
**Re: st: probability question** - Previous by thread:
**st: RE: Problems adding large numbers** - Next by thread:
**st: gzsave and zipsave** - Index(es):

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