<?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 Catx to reshape data horizontally in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514969#M138909</link>
    <description>&lt;P&gt;Unlike a similar question you guys just helped me with - about how to de-dup a list of comma delimited values stored in a variable.&amp;nbsp; My challenge is time is to find a method to prevent the CATX function from ever putting a duplicate date value into the list&amp;nbsp;to begin with.&amp;nbsp; If you have any thoughts on how to alter the code below to accomplish this I'd really appreciate the insights.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following piece of SAS code takes data rows that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;BENE&amp;nbsp; &amp;nbsp;FROM_DT &lt;/U&gt;(stored in a SAS dataset as SAS date values)&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 23OCT2010&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 11NOV2015&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 11NOV2015&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 15DEC2011&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 11NOV2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And changes the multiple rows into a single row by Bene with the dates all transformed into a single variable named From_Date_List using the CATX function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;BENE&lt;/U&gt;&amp;nbsp; &amp;nbsp;&lt;U&gt;FROM_DT_LIST&lt;/U&gt;&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 23OCT2010,&amp;nbsp;&lt;SPAN&gt;11NOV2015,&amp;nbsp;11NOV2015,&amp;nbsp;15DEC2011,&amp;nbsp;11NOV2015&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT DATA=FROM_DT_RESHAPE; BY BENE_SK; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA FROM_DT_RESHAPED;&lt;BR /&gt;LENGTH FROM_DT_LIST $1000;&lt;BR /&gt;DO UNTIL (LAST.BENE);&lt;BR /&gt;SET FROM_DT_RESHAPED;&lt;BR /&gt;BY BENE;&lt;BR /&gt;FROM_DT_LIST = CATX(', ',FROM_DT_LIST, PUT(FROM_DT, DATE9.));&lt;BR /&gt;END;&lt;BR /&gt;KEEP FROM_DT_LIST BENE;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Nov 2018 02:39:27 GMT</pubDate>
    <dc:creator>buechler66</dc:creator>
    <dc:date>2018-11-21T02:39:27Z</dc:date>
    <item>
      <title>Catx to reshape data horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514969#M138909</link>
      <description>&lt;P&gt;Unlike a similar question you guys just helped me with - about how to de-dup a list of comma delimited values stored in a variable.&amp;nbsp; My challenge is time is to find a method to prevent the CATX function from ever putting a duplicate date value into the list&amp;nbsp;to begin with.&amp;nbsp; If you have any thoughts on how to alter the code below to accomplish this I'd really appreciate the insights.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following piece of SAS code takes data rows that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;BENE&amp;nbsp; &amp;nbsp;FROM_DT &lt;/U&gt;(stored in a SAS dataset as SAS date values)&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 23OCT2010&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 11NOV2015&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 11NOV2015&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 15DEC2011&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 11NOV2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And changes the multiple rows into a single row by Bene with the dates all transformed into a single variable named From_Date_List using the CATX function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;BENE&lt;/U&gt;&amp;nbsp; &amp;nbsp;&lt;U&gt;FROM_DT_LIST&lt;/U&gt;&lt;/P&gt;&lt;P&gt;12345&amp;nbsp; 23OCT2010,&amp;nbsp;&lt;SPAN&gt;11NOV2015,&amp;nbsp;11NOV2015,&amp;nbsp;15DEC2011,&amp;nbsp;11NOV2015&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT DATA=FROM_DT_RESHAPE; BY BENE_SK; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA FROM_DT_RESHAPED;&lt;BR /&gt;LENGTH FROM_DT_LIST $1000;&lt;BR /&gt;DO UNTIL (LAST.BENE);&lt;BR /&gt;SET FROM_DT_RESHAPED;&lt;BR /&gt;BY BENE;&lt;BR /&gt;FROM_DT_LIST = CATX(', ',FROM_DT_LIST, PUT(FROM_DT, DATE9.));&lt;BR /&gt;END;&lt;BR /&gt;KEEP FROM_DT_LIST BENE;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 02:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514969#M138909</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2018-11-21T02:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Catx to reshape data horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514970#M138910</link>
      <description>Do your dates have any order? It doesn't in your demo, but if it does in real life it will help if you can add another BY variable. Also, why are you doing this? I suspect there's an alternative that's easier, ie Transpose and retranspose.</description>
      <pubDate>Wed, 21 Nov 2018 02:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514970#M138910</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-21T02:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Catx to reshape data horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514971#M138911</link>
      <description>What's your expected output?
BENE   FROM_DT_LIST

12345  23OCT2010, 11NOV2015, 11NOV2015, 15DEC2011, 11NOV2015</description>
      <pubDate>Wed, 21 Nov 2018 02:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514971#M138911</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-21T02:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Catx to reshape data horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514973#M138913</link>
      <description>No, the dates have no specific order. This is my required method of accomplishing the task so Transpose isn't' an option for me. Thanks tho.</description>
      <pubDate>Wed, 21 Nov 2018 02:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514973#M138913</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2018-11-21T02:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Catx to reshape data horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514974#M138914</link>
      <description>The expected output would be (dates in any order):&lt;BR /&gt;&lt;BR /&gt;BENE FROM_DT_LIST&lt;BR /&gt;&lt;BR /&gt;12345 23OCT2010, 11NOV2015, 15DEC2011</description>
      <pubDate>Wed, 21 Nov 2018 02:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514974#M138914</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2018-11-21T02:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Catx to reshape data horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514975#M138915</link>
      <description>&lt;P&gt;ok, that's easy&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input BENE   FROM_DT :date9.; 
format from_dt date9.;
cards;
12345  23OCT2010
12345  11NOV2015
12345  11NOV2015
12345  15DEC2011
12345  11NOV2015
;


data want;
array t(999) $9 _temporary_;
call missing(of t(*),n);
do until(last.bene);
set have;
by bene;
temp=put(from_dt,date9.);
if temp not in t then do;
n+1;
t(n)=temp;
end;
end;
want_list=catx(', ',of t(*));
keep bene want_list;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 03:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/514975#M138915</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-21T03:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Catx to reshape data horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/515164#M138978</link>
      <description>Thanks so much for taking the time to help. I really appreciate it.</description>
      <pubDate>Wed, 21 Nov 2018 17:10:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-to-reshape-data-horizontally/m-p/515164#M138978</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2018-11-21T17:10:38Z</dc:date>
    </item>
  </channel>
</rss>

