DaveC,
Yes there is a way and with SAS there are multiple ways to do things. Below is a method, not neccessarily the best but for a new to SAS user this will show you some of the data processing power of SAS.
Also read the documentation again and again and again. When I code in SAS I always have the documentation page up in my browser.
http://support.sas.com/onlinedoc/913/docMainpage.jsp
I would check out in the documentation
Base SAS -> SAS Language Reference: Concepts -> DATA Step Concepts
Now for your solution.
data One;
input Household_ID $ Sex;
datalines;
0001 1
0001 1
0002 1
0002 2
0003 1
0004 1
;
run;
proc sort data=One;
by Household_ID Sex;
run;
data Two;
set One;
by Household_ID Sex;
if first.sex ne last.sex;
run;
* for extra fun...;
data Behind_the_scenes;
set one;
by Household_ID sex;
/* first. = 1 for the first occurrence of the value
last. = 1 for the last occurrence of the value
so in your example: obs1 and 2 are duplicates
Houshold_ID =0001
for obs=1, Houshold_ID =0001 sex=1, first.household_id=1 and last.household_id=0
first.sex =1 and last.sex=0
for obs=2, Houshold_ID =0001 sex=1, first.household_id=0 and last.household_id=1
first.sex =0 and last.sex=1
..
Notices:
for obs=5, Houshold_ID =0003 sex=1, first.household_id=1 and last.household_id=1
first.sex =1 and last.sex=1
since there is only 1 record for household_id 0003 the first and last occurence is the same record hence first.household_id=last.household_id
*/
first_Household_ID=first.Household_ID;
last_Household_ID=last.Household_ID;
first_sex=first.sex;
last_sex=last.sex;
run;