Hi, I am looking for a way to combine 2 records in a single dataset.
These 2 records have duplicate IDs but i can't figure out how to make them into a single row.
I am hoping to make them into something like this;
POLICYID RIDER_LISTS
1 I100786-4599318572 RTWMR4,RTWWP1,RTWMR2,RTWHB1
Thanks in advance!
Here is an example
data have;
input id $ list $;
datalines;
123 ab,cd
123 ef,ghj
012 abcd
;
data want;
length newList $200; /* Make new list large enough to hold the longer lists */
retain newList;
set have;
by id notsorted;
if first.id then newList = list;
else newList = catx(",", newList, list);
if last.id then output;
rename newList=list;
drop list;
run;
By what rule do you know they are from the same id?
Does the number of records per policy vary? Or is it always 2?
From the excel tables. But unsure why it became null..
Here is an example
data have;
input id $ list $;
datalines;
123 ab,cd
123 ef,ghj
012 abcd
;
data want;
length newList $200; /* Make new list large enough to hold the longer lists */
retain newList;
set have;
by id notsorted;
if first.id then newList = list;
else newList = catx(",", newList, list);
if last.id then output;
rename newList=list;
drop list;
run;
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.