Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Martin Weiss" <martin.weiss1@gmx.de> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | st: RE: making data duplicate in terms of several variables in case of a given variable taking identical values |
Date | Mon, 5 Jul 2010 21:09:28 +0200 |
<> *********** clear* input str10(zipcode prefecture) int(towncode areacode) "0010027" "hokkaido" 100 1100 "0010029" "hokkaido" 100 1100 "0010029" "" . . "0010030" "hokkaido" 100 1100 "0200822" "iwate" 201 3201 "0200823" "" . . "0200823" "iwate" 201 3201 "0200831" "iwate" 201 3201 end compress li, noo sepby(zipcode) bys zipcode (prefecture towncode areacode): replace prefecture=prefecture[_N] bys zipcode (towncode areacode): replace towncode=towncode[1] bys zipcode (areacode): replace areacode=areacode[1] l, sepby(zipcode) *********** HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Ekaterina Hertog Sent: Montag, 5. Juli 2010 20:59 To: statalist@hsphsun2.harvard.edu Subject: st: making data duplicate in terms of several variables in case of a given variable taking identical values Dear all, I have some data which looks like this zipcode prefecture towncode areacode 0010027 hokkaido 100 1100 0010029 hokkaido 100 1100 0010029 . . . 0010030 hokkaido 100 1100 0200822 iwate 201 3201 0200823 . . . 0200823 iwate 201 3201 0200831 iwate 201 3201 I use Stata 11. I would like to make my observations identical in terms of prefecture, towncode and areacode when they are identical in terms of zipcode. I think that the only cases where prefecture, towncode and areacode vary while zipcodes are identical are when prefecture, towncode and areacode are sometimes missing and sometimes not, but I would like to check that before I do the necessary replacements. I looked into duplicate commands, but did not seem to find a good solution. I would be most grateful for any pointers. Sincerely yours, katya * * 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/