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
Scott Merryman <[email protected]>
To
[email protected]
Subject
Re: st: Reshaping data from list form and grouping by one variable
Date
Wed, 8 Jan 2014 07:41:50 -0600
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/