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]

From |
Ekaterina Hertog <ekaterina.hertog@sociology.ox.ac.uk> |

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

Subject |
Re: st: RE: making data duplicate in terms of several variables in case of a given variable taking identical values |

Date |
Thu, 08 Jul 2010 18:18:22 +0400 |

Dear Martin, Sorry for the late reply. Thank you very much for your advice!

When I ran bys zipcode: gen byte prefvaries=prefecture[1]!=prefecture[_N]

I modified the code you suggested as follows bys zipcode (prefecture): gen byte prefvaries=prefecture[1]!=prefecture[_N] and it fixed the problem. Thanks a lot, Katya Martin Weiss wrote:

<>" Ithink that the only cases where prefecture, towncode and areacode varywhile zipcodes are identical are when prefecture, towncode and areacodeare sometimes missing and sometimes not, but I would like to check thatbefore I do the necessary replacements."You have to check those conditions one by one: *********** 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: gen byte prefvaries=prefecture[1]!=prefecture[_N] by zipcode: gen byte townvaries=towncode[1]!=towncode[_N] by zipcode: gen byte areavaries=areacode[1]!=areacode[_N] by zipcode: egen missings=total(mi(prefecture,towncode, areacode))by zipcode: gen byte onlysomemiss=missings!=_N & missings!=0drop missings//all conditions fulfilled? gen byte complies=prefvaries+townvaries+areavaries+onlysomemiss==4 li, noo sepby(zipcode) ab(15) *********** 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. Ithink that the only cases where prefecture, towncode and areacode varywhile zipcodes are identical are when prefecture, towncode and areacodeare sometimes missing and sometimes not, but I would like to check thatbefore I do the necessary replacements.I looked into duplicate commands, but did not seem to find a goodsolution. 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/

-- Ekaterina Hertog (née Korobtseva) Career Development Fellow Department of Sociology and Nissan Institute of Japanese Studies University of Oxford 27 Winchester Road Oxford OX2 6NA United Kingdom * * 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: making data duplicate in terms of several variables in case of a given variable taking identical values***From:*Ekaterina Hertog <ekaterina.hertog@sociology.ox.ac.uk>

**st: RE: making data duplicate in terms of several variables in case of a given variable taking identical values***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: RE: one-tailed tests** - Next by Date:
**Re: st: Subgroup analysis** - Previous by thread:
**st: RE: RE: making data duplicate in terms of several variables in case of a given variable taking identical values** - Next by thread:
**st: Extracting specific elements from a matrix** - Index(es):