Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Reshape

From   "Carter Rees" <>
To   <>
Subject   st: Reshape
Date   Wed, 19 Jul 2006 22:07:08 -0400

Using Stata/SE9.2 Windows XP

I have a file called frnddelinq in the following format.  Variable aid is a
unique identifier for a student and the vars friend1 and friend2 (the friend
vars actually go out to friend10) are the unique aid for each of the
student's friends.  The vars with the prefix smoke and steal are tied to
that specific friend.  So, this file is at the student unit of analysis with
all of his/her friends listed in wide form along with their dichotomous
score on some delinquency variables.

aid	friend1	smoke1	steal1	friend2	smoke2	steal2
111	 112	        1	        0	         113	   0
112	 113	        0	        1	         114	   1
113	 115	        1	        0	         111	   0
114	 115	        1	        0	         113         0
115	  .	        .	        .	          .	         .

In another file called studentdelinq I have all of my delinquency variables
(smoke and steal are two of six total) for each aid in my data set.  The var
friend in this file is the same as aid.

aid smoke steal friend
111	0     0    111
112   1     0    112
113   0     1    113
114   1     1    114
115   1     0    115

What I would like to do is merge studentdelinq to frnddelinq using aid after
frnddelinq has been reshaped into a long format.  The ultimate goal is to
end up with a file in a wide format which has the delinquency variables not
only for a student's friends but also their friends.  (Yes this file will
have a lot of variables) I have reshaped long my frnddelinq file and merged
my student delinq file to it and things seem to be working fine.  However,
when I reshape my data back to wide I don't end up with a student's friends
plus the friends of those friends.  What I get is a file that looks just
like the original frnddelinq.

I think that my problem comes from my variable naming conventions(?).

Your thoughts are appreciated.


Carter Rees
School of Criminal Justice
University at Albany, SUNY

*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index