Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Problem with creating new ID with other ID variables


From   nola l <nola0908@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Problem with creating new ID with other ID variables
Date   Mon, 10 Jun 2013 12:37:07 -0400

Hello,

I have a data set like below:
     +------------------------------------+
      | h1aq1   h1aq2   h1aq3   h1aq4   EA |
      |------------------------------------|
   1. |   101       2       4       2    2 |
   2. |   101       2       4       2    2 |
   3. |   102       .       .       .    . |
   4. |   101       2       4       2    2 |
   5. |   101       2       4       2    2 |
      |------------------------------------|
   6. |   106       .       .       .    . |
   7. |   102       1       1       4    1 |
   8. |   102       1       1       4    1 |
   9. |   102       1       1       4    1 |
  10. |   102       1       1       4    1 |
      |------------------------------------|
  11. |   102       1       1       4    1 |
  12. |   102       1       1       4    1 |
  13. |   102       1       1       8    2 |
  14. |   102       1       1       8    2 |
  15. |   102       1       1       8    2 |
and I would like to generate a ID which should looks like
CID=EA+ h1aq4*100+ h1aq3*10000+ h1aq2*1000000+ h1aq1*100000000

which means that CID for record 1 is 10102040202.

When I use following command in Stata12:
gen CID=EA+ h1aq4*100+ h1aq3*10000+ h1aq2*1000000+ h1aq1*100000000

format %16.0g CID

I got CID=10102040576 for record 1.

Where did I mess up? Could you guys help me out on this and tell me
how to could create correct ID?

Thanks,
Nola
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index