BookmarkSubscribeRSS Feed
Cooksam13
Fluorite | Level 6

Hi 

I have a data set that includes the mother and child information in one row - they are combined using their shared family ID, but what just realized that if there are multiple children with the same family ID only one match with the mother happens. 

How do I duplicate the mother information to merge with the 2nd or 3rd  etc. child information. and maintain one whole data set? 

thank you

6 REPLIES 6
SASKiwi
PROC Star

We can't provide a solution to your problem until you provide some sample mother and child data and details of what you would like it changed to. 

Reeza
Super User

How was the child and family information merged/combined? Sounds like something went wrong in that step, so that step should be fixed. 

 

Can you show the code or logic used?

Or the data structure. Fake data is fine but ensure the output expected matches with the input shown, ie provide a reproducible example. 

Cooksam13
Fluorite | Level 6

first I combined the demographics data with the screening data 

 

DATA have;
MERGE screen
dem;
BY ID_Person;
RUN;

 

then separated the child and mother data 

 

data adult;
set have;
if Adult = 'Adult' then output;
run;
data adult2;
set adult;
if CD_Gender = 'Female' then output;
run;

 

data child;
set have;
if child = 'Child' then output;
run;

 

then I did some editing to some other variables like adding "A_" before all the variables associated with "Adult" so that when I merged them it wouldn't overwrite it - except for the variable "ID_Family"

 

next I sort it by the ID_family that both of the data sets have

proc sort data = child2;
by ID_family;
run;

proc sort data = adult;
by ID_family;
run;

 

data want;
Merge child
adult;
by ID_family;
run;

Reeza
Super User
You'll need to show your actual code, but your code as shown references a data set called CHILD2 that isn't shown somewhere.
Check your log thoroughly for notes and such. Your general logic is correct, so it's a specific detail somewhere, either in the code or data that's wrong.
Cooksam13
Fluorite | Level 6

sorry that is wrong I meant to say just "child" I think it was a typo error that is the code i used i can't show the rename section as it is a HIPPA problem

Reeza
Super User

HIPAA doesn't apply to variable names, it applies to patient data and you can make fake data. Unfortunately with what you've shown I cannot assist any further. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 755 views
  • 0 likes
  • 3 in conversation