Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: Reshaping data from list form and grouping by one variable


From   Daniel Tucker <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Reshaping data from list form and grouping by one variable
Date   Wed, 8 Jan 2014 14:02:26 +0000

Thank you so much Scott. That has worked perfectly. I had tried reshape wide but had just used gen=_n rather than "bys state: gen j=_n"

Thanks again!

Daniel

----------------------------------------
> Date: Wed, 8 Jan 2014 07:41:50 -0600
> Subject: Re: st: Reshaping data from list form and grouping by one variable
> From: [email protected]
> To: [email protected]
>
> Something like this?
>
> clear
> input str1 state str1 neighbors
> a b
> a c
> a e
> b a
> b d
> c a
> c d
> d b
> d c
> e a
> end
> bys state : gen j = _n
> reshape wide neigh, i(state) j(j)
> l
>
> Scott
>
>
>
> On Wed, Jan 8, 2014 at 7:16 AM, Daniel Tucker
> <[email protected]> wrote:
>> Hello all,
>>
>> I’m relatively new to STATA and was wondering whether you
>> could help me. I am trying to construct a dataset of every countries
>> contiguous borders. I currently have a list of all of the land borders
>> in the form of:
>>
>> StateA, StateB
>> AFG, CHI
>> AFG, IRA
>> AFG, PAK
>> … and so on.
>>
>> In total there are 618 observations. I want to instead have it so that the
>> StateA variable has only unique values and all of its relationships are
>> listed in the following manner:
>> StateA, StateB1, StateB2, StateB3...
>> AFG, CHI, IRA, PAK...ALB, GRE, MAC, MTG ...
>>
>> The most land borders is 15 so it would have to go up to StateB15. I am
>> unsure if there is a command which would help me to do this and would
>> much appreciate any assistance that you could provide. If not, I will
>> have to input it manually. Thanks in advance for your assistance.
>> Kind regards,
>>
>> Daniel Tucker
>
> *
> * 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/ 		 	   		  
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index