<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to concatenate records with duplicates and non duplicates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648468#M194264</link>
    <description>&lt;P&gt;The logic you want is unclear. Why 5 records output?&lt;/P&gt;
&lt;P&gt;Does this help?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT (keep=TOTAL);
  length TOTAL $500;
  set HAVE;
  by EMP_ID;
  if first.EMP_ID then TOTAL=EMP_ID;
  TOTAL=catx('|',TOTAL,TRANS_NO,ACCT_NO,ACCT_NAME,vvalue(TRANS_DATE),TRANS_AMT,FNAME,LNAME,vvalue(DOB),'***');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 May 2020 02:31:44 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-05-18T02:31:44Z</dc:date>
    <item>
      <title>How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648462#M194259</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;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,&amp;nbsp;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).&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want the output to look like this:&lt;/P&gt;&lt;P&gt;|ABCD|123XER|12345|JonasLLC|17May2020|1500|***|John|Smith|02mar1990|***|Sarah|Frost|22Jun1995|***&lt;BR /&gt;|458ABC|45689|Jonas|11May2020|20000|***|Noel|White|12may2000|***|Tim|Kerry|16jun2005|***&lt;BR /&gt;|784TYU|54321|JonasLLC|17Mar2020|15000|Tom|Baker|02mar2010|&lt;BR /&gt;|WXYZ|342VCF|67890|Chipotle|15May2020|10000|***|Nick|Black|15Jun1978|***|Ronney|Black|15Jun2000|***&lt;BR /&gt;|987RTV|568471|Macys|18jan2020|45000|***|Mike|Meyer|14Feb1992|***|Nancy|Meyer|14Feb2012|&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 01:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648462#M194259</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-05-18T01:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648466#M194262</link>
      <description>&lt;P&gt;The output would have 2 records for two employee ids.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 02:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648466#M194262</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-05-18T02:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648468#M194264</link>
      <description>&lt;P&gt;The logic you want is unclear. Why 5 records output?&lt;/P&gt;
&lt;P&gt;Does this help?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT (keep=TOTAL);
  length TOTAL $500;
  set HAVE;
  by EMP_ID;
  if first.EMP_ID then TOTAL=EMP_ID;
  TOTAL=catx('|',TOTAL,TRANS_NO,ACCT_NO,ACCT_NAME,vvalue(TRANS_DATE),TRANS_AMT,FNAME,LNAME,vvalue(DOB),'***');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 May 2020 02:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648468#M194264</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-18T02:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648475#M194268</link>
      <description>&lt;P&gt;Hi ChrisNZ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thanks for responding. There is supposed be two records (as there are only two employee ids). On top of it. I have to separate out repeated data (duplicate, 123XER ABCD 12345 JonasLLC 17May2020 1500 (red color text)) from non duplicate data (John Smith , 02mar1990&amp;nbsp; and&amp;nbsp;Sarah Frost ,&amp;nbsp;22Jun1995). Take a look at the first two records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John Smith &lt;FONT color="#FF0000"&gt;123XER ABCD 12345 JonasLLC 17May2020 1500&lt;/FONT&gt; 02mar1990&lt;BR /&gt;Sarah Frost&lt;FONT color="#FF0000"&gt; 123XER ABCD 12345 JonasLLC 17May2020 1500&lt;/FONT&gt; 22Jun1995&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have two employee_ids and each employee id should have repeated part of record concatenated with nonrepeated part of the code.&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="nar.JPG" style="width: 668px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39548i0DB8EB89727AEF41/image-size/large?v=v2&amp;amp;px=999" role="button" title="nar.JPG" alt="nar.JPG" /&gt;&lt;/span&gt;The highlighted text is repeated in two records at least. The result would look like this. The highlighted text is repeated in two records and rest of the string is not repeated record (ie, fname,lname and date of birth).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nar1.JPG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39549iAC77FD46AD69F20C/image-size/large?v=v2&amp;amp;px=999" role="button" title="nar1.JPG" alt="nar1.JPG" /&gt;&lt;/span&gt;&amp;nbsp;Let me know if you need more clarity.&lt;/P&gt;&lt;P&gt;Thanks again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 03:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648475#M194268</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-05-18T03:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648476#M194269</link>
      <description>&lt;P&gt;The output will have two records only( as there are 2 employee ids ABCD and WXYZ).&amp;nbsp; Space on the page is not allowing me to put all of the single employee on the same line. Though it looks 4 lines, but it should have two lines of records.&lt;/P&gt;&lt;P&gt;The output should look like this&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;|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|&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;|WXYZ|342VCF|67890|Chipotle|15May2020|10000|***|Nick|Black|15Jun1978|***|Ronney|Black|15Jun2000|***|987RTV|568471|Macys|18jan2020|45000|***|Mike|Meyer|14Feb1992|***|Nancy|Meyer|14Feb2012|&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 03:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648476#M194269</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-05-18T03:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648490#M194274</link>
      <description>&lt;P&gt;Just add one more line to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT (keep=TOTAL);
  length TOTAL $500;
  set HAVE;
  by EMP_ID;
  if first.EMP_ID then TOTAL=EMP_ID;
  TOTAL=catx('|',TOTAL,TRANS_NO,ACCT_NO,ACCT_NAME,vvalue(TRANS_DATE),
             TRANS_AMT,FNAME,LNAME,vvalue(DOB),'***');
  if last.EMP_ID then output;  /* avoid multiple lines per emp_id */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 May 2020 06:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648490#M194274</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-05-18T06:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648491#M194275</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sort data=HAVE ;
	by EMP_ID TRANS_NO ACCT_NO ACCT_NAME TRANS_DATE TRANS_AMT;
run;

data WANT ;*(keep=TOTAL);
  length TOTAL $500;
  retain TOTAL ;
  set HAVE;
	by EMP_ID TRANS_NO ACCT_NO ACCT_NAME TRANS_DATE TRANS_AMT;
  if first.EMP_ID then TOTAL=EMP_ID;
  if first.TRANS_AMT then TOTAL=catx('|',TOTAL,TRANS_NO,ACCT_NO,ACCT_NAME,vvalue(TRANS_DATE),TRANS_AMT,'***');
  TOTAL=catx('|',TOTAL,FNAME,LNAME,vvalue(DOB),'***');
  if last.EMP_ID then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please use the proper way to insert code (running man icon) and text (&amp;lt;/&amp;gt; icon) to avoid formatting issues.&lt;/P&gt;
&lt;PRE&gt;ABCD|123XER|12345|JonasLLC|17MAY2020|1500|Sarah|Frost|22JUN1995|***|John|Smith|02MAR1990|***|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|***&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 06:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648491#M194275</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-18T06:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648517#M194288</link>
      <description>&lt;P&gt;Thanks Chris. This works for me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 11:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648517#M194288</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-05-18T11:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate records with duplicates and non duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648519#M194289</link>
      <description>&lt;P&gt;Thanks for the help Shmuel.&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 11:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-records-with-duplicates-and-non-duplicates/m-p/648519#M194289</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2020-05-18T11:01:58Z</dc:date>
    </item>
  </channel>
</rss>

