Hi guys, I have a dataset that I got from joining two tables. Since there are multiple users on a given account, I have duplicate values. I am trying to find a way to code the out put listed below. As you see, I want to concatenate records based on a individual employee id and trans_no, acct_no, acct_name, trans_date,trans_amt along with employee name and his dob. I tried below code, but it's not working out as I want to concatenate duplicate part of the record to non-duplicated record (employee fname,lname,dob). data have;
input fname $ lname $ trans_no $ emp_id $ acct_no $ acct_name $ trans_date date9. trans_amt dob date9. ;
FORMAT DOB TRANS_DATE DATE9.;
cards;
John Smith 123XER ABCD 12345 JonasLLC 17May2020 1500 02mar1990
Sarah Frost 123XER ABCD 12345 JonasLLC 17May2020 1500 22Jun1995
Noel White 458ABC ABCD 45689 Jonas 11May2020 20000 12may2000
Tim Kerry 458ABC ABCD 45689 Jonas 11May2020 20000 16jun2005
Tom Baker 784TYU ABCD 54321 JonasLLC 17Mar2020 15000 02mar2010
Nick Black 342VCF WXYZ 67890 Chipotle 15May2020 10000 15Jun1978
Mike Meyer 987RTV WXYZ 568471 Macys 18jan2020 45000 14Feb1992
Ronney Black 342VCF WXYZ 67890 Chipotle 15May2020 10000 15Jun2000
Nancy Meyer 987RTV WXYZ 568471 Macys 18jan2020 45000 14Feb2012
;
run;
PROC SORT DATA=HAVE ;
BY emp_id ;
RUN;
data want (keep=total);
LENGTH TOTAL $500;
set have;
by emp_id;
IF FIRST.EMP_ID THEN TOTAL= STRIP(TOTAL)||'|'||STRIP(emp_id)||'|'||STRIP(trans_no)||'|'||STRIP(acct_no)||'|'||STRIP(acct_name)||'|'||STRIP(PUT(trans_date, date9.))||'|'||
STRIP(PUT(trans_amt,8.))||'|'||STRIP(fname)||'|'||STRIP(lname)||'|'||STRIP(PUT(dob,DATE9.))||'|'||'***'||'|' ;
ELSE DELETE;
RUN; I want the output to look like this: |ABCD|123XER|12345|JonasLLC|17May2020|1500|***|John|Smith|02mar1990|***|Sarah|Frost|22Jun1995|*** |458ABC|45689|Jonas|11May2020|20000|***|Noel|White|12may2000|***|Tim|Kerry|16jun2005|*** |784TYU|54321|JonasLLC|17Mar2020|15000|Tom|Baker|02mar2010| |WXYZ|342VCF|67890|Chipotle|15May2020|10000|***|Nick|Black|15Jun1978|***|Ronney|Black|15Jun2000|*** |987RTV|568471|Macys|18jan2020|45000|***|Mike|Meyer|14Feb1992|***|Nancy|Meyer|14Feb2012| Thanks in advance.
... View more