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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.