Statalist


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

Re: st: RE: problem creating unique identifier


From   Christopher Hajzler <[email protected]>
To   [email protected]
Subject   Re: st: RE: problem creating unique identifier
Date   Sun, 6 Dec 2009 14:38:15 -0600

Thank you, Martin.  I was could not imagine when I initially
discovered the problem that there was a standard reason for what was
going on, but I get it now (on a basic level).  Using "double" seems
to be working out fine, and I really appreciate your help.

Incidentally, would using "double" have worked for a larger number of
digits, or did this function give me just enough extra precision to
accomplish the current task?

Cheers,
Chris

On Sun, Dec 6, 2009 at 1:59 PM, Martin Weiss <[email protected]> wrote:
>
> <>
>
> See also http://www.stata.com/support/faqs/data/prec.html, NJC`s
> http://www.stata-journal.com/sjpdf.html?articlenum=dm0022  and the entry
> "Precision of numeric storage types" in -help data_types-...
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Christopher
> Hajzler
> Sent: Sonntag, 6. Dezember 2009 20:47
> To: [email protected]
> Subject: st: problem creating unique identifier
>
> Dear Statalist,
>
> My version of Stata is doing something quite strange (Version 8.0
> intercooled).  I have several variables which are contained in
> separate data files, and I want to merge them by creating a unique
> identifier for each observation (over which I can sort the data - I
> realize it is not strictly necessary to do it this way, but I thought
> this method would help avoid errors).  Each observation represents a
> city pair (just over 100 cities), and an "item", and in each file I've
> created the variable using the following command:
> gen newid = 0
> replace newid = 1000000*itemid + 1000*cityid1 + cityid2
>
> For some reason Stata will only do a partial job - it seems to be
> getting the itemid and cityid1 right when producing newid (the first 4
> or 5 digits), and "almost" gets cityid2 right, assigning the correct
> values every few observations but then incorrectly allocating the same
> value to adjacent observations. For example, one file reads:
>
> newid                itemid       cityid1      cityid2      var1
> ...
> 22061006           22             61              6           ...
> 22061008           22             61              8           ...
> 22061008           22             61              9           ...
> 22061008           22             61              7           ...
> 22061010           22             61              10          ...
> 22061012           22             61              13          ...
> ...
>
> I have worked with much larger datasets, so I cannot imagine memory
> allocation is an issue. Any other ideas?
>
> Best wishes,
> Chris
>
> *
> *   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/
>

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