LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 2 Oct 2009 13:05:50 -0500
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: Best way to rearrange dyadic data
Comments: To: msz03@albany.edu
In-Reply-To:  <63328.150.142.232.4.1254493114.squirrel@webmail.albany.edu>
Content-Type: text/plain; charset=ISO-8859-1

Thanks for that program that explains Peter's question. The COMPARE seems like a good idea, and after seeing your program I think you could just sort and use WHERE data set option. No need to create male and female data sets.

The ID statement should handle unpaired Couples and LISTOBS will report on couples with missing rows.

data test; input (Couple ID Sex A11 A12) (2*:$5. :$6. 2*&$32.); cards; 10260 10261 Male Single, Never Married Single, Never Married 10260 10262 Female Widowed Widowed 10380 10381 Male Married Married 10380 10382 Female Married Married 10280 10281 Male Married Married 10280 10282 Female Married Married 10290 10291 Male Married Married ;;;; run; proc sort; by couple; run; proc compare base=test(where=(sex eq: 'M') label='Males') compare=test(where=(sex eq: 'F') label='Females') listobs ; id couple; var a1:; run;

On 10/2/09, Mike Zdeb <msz03@albany.edu> wrote: > hi Peter ... how about putting the observations into two data sets and using PROC COMPARE > > if there's one observation in each data set per couple, this should work > > > data both; > input Couple ID Sex : $6. A11 & : $25.; > datalines; > 10260 10261 Male Single, Never Married > 10260 10262 Female Widowed > 10380 10381 Male Married > 10380 10382 Female Married > 10280 10281 Male Married > 10280 10282 Female Married > ; > run; > > * make two data sets; > data male female; > set both; > select; > when (sex eq : "M") output male; > when (sex eq : "F") output female; > otherwise delete; > end; > drop id sex; > run; > > * in case the original data was not in couple order; > proc sort data=male; > by couple; > run; > > proc sort data=female; > by couple; > run; > > * no need to make new variable names; > proc compare base=male compare=female; > run; > > -- > Mike Zdeb > U@Albany School of Public Health > One University Place > Rensselaer, New York 12144-3456 > P/518-402-6479 F/630-604-1475 > > > Good morning all > > > > It's been a while since I've asked a question :-) > > > > Before posting this one, I searched SAS-L and found similar questions (including some by me!) but I also found advice that each case is a little > > different.... so... > > > > I have a data set with data on heterosexual couples. Currently, each line is an indvidual, and there are ~1000 variables. Each line includes > > > > COUPLE - which is the couple ID > > ID - which is the individual's ID > > SEX - which is the individual's sex > > many many other variables, e.g. marital status. So, it looks something like this > > --------------------------------------- > > DATA HAVE > > Couple ID Sex A11 > > 10260 10261 Male Single, Never Married > > 10260 10262 Female Widowed > > 10380 10381 Male Married > > 10380 10382 Female Married > > 10280 10281 Male Married > > 10280 10282 Female Married > > > > etc for c. 300 couples and 1000 variables > > -------------------------------------------- > > for some parts of this analysis (it's going to be a long project - many months, anyway, with lots of analysis) this is the best order of data. But > > some of the initial work is checking whether the two members of a dyad agree. > > > > for this, I *think* the best arrangement is > > > > Couple A11M A11F > > 10260 Single, Never Married Widowed > > 10380 Married Married > > > > (that's A with two ones) > > > > Then I could just do > > PROC FREQ; > > table a11M*a11F; > > run; > > etc. > > > > The nice thing is that every dyad has one male and one female, and the male always has a 1 suffix and the female a 2. > > > > The hard thing is that there are hundreds of variables, some numeric, some character, many with a lot of missing data. And the variables have been > > named rather capriciously (e.g. the MARITAL variable is A11, other names are such things as D6_M). The variables have good labels, and have formats > > attached. > > > > Any hints appreciated as always. > > > > Note that I have to be out from 10 to about 2 or 3, Eastern time, so, if I don't reply, that's why. > > > > Thanks as always > > > > Peter > > > > Peter L. Flom, PhD > > Statistical Consultant > > Website: www DOT peterflomconsulting DOT com > > Writing; http://www.associatedcontent.com/user/582880/peter_flom.html > > Twitter: @peterflom > > >


Back to: Top of message | Previous page | Main SAS-L page