<?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: Concatenate and group by problem in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115075#M31824</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both for your replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PGStats solution work as described.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nicnad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Aug 2013 20:13:50 GMT</pubDate>
    <dc:creator>nicnad</dc:creator>
    <dc:date>2013-08-19T20:13:50Z</dc:date>
    <item>
      <title>Concatenate and group by problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115072#M31821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following table :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 587px;"&gt;&lt;TBODY&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; width: 50pt;" width="67"&gt;&lt;P&gt;requestid&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none; width: 56pt;" width="75"&gt;&lt;P&gt;CRITERIAID&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none; width: 239pt;" width="318"&gt;&lt;P&gt;criteria&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none; width: 95pt;" width="127"&gt;&lt;P&gt;criteria_value&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;11111&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Raisons de s'interroger sur provenance des fonds&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Oui&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;11111&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Nature des opérations sensible&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Magasins de pièces&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;22222&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Activités dans des pays étrangers sensibles&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Colombie&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;22222&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Activités dans des pays étrangers sensibles&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Malaisie&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;22222&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Activités dans des pays étrangers sensibles&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Iraq&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;22222&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Nature des opérations sensible&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;Lave-autos&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to do the following :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. For each requestid, concatenate each criteria with ": " and the criteria value&lt;/P&gt;&lt;P&gt;2. For each requestid, for the same criteriaid, use the criteria once and concatenate each criteria value with a comma.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The end table would look like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 664px;"&gt;&lt;TBODY&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; width: 76pt;" width="101"&gt;&lt;P&gt;requestid&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none; width: 76pt;" width="101"&gt;&lt;P&gt;criteriaid&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none; width: 347pt;" width="462"&gt;&lt;P&gt;my_criteria_final&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;11111&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none; width: 347pt;" width="462"&gt;&lt;P&gt;Raisons de s'interroger sur provenance des fonds : Oui&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;11111&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none; width: 347pt;" width="462"&gt;&lt;P&gt;Nature des opérations sensible : Magasins de pièces&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;22222&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none; width: 347pt;" width="462"&gt;&lt;P&gt;Activités dans des pays étrangers sensibles : Colombie, Malaisie, Iraq&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; border-top: none;"&gt;&lt;P&gt;22222&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none; width: 347pt;" width="462"&gt;&lt;P&gt;Natures des opérations sensible : Lave-Autos&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your help and time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 16:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115072#M31821</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-08-19T16:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate and group by problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115073#M31822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's how:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;length criteria $64 criteria_value $32;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;input requestid CRITERIAID criteria &amp;amp; criteria_value &amp;amp;;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;11111 1 Raisons de s'interroger sur provenance des fonds&amp;nbsp; Oui&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;11111 2 Nature des opérations sensible&amp;nbsp; Magasins de pièces&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;22222 3 Activités dans des pays étrangers sensibles&amp;nbsp; Colombie&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;22222 3 Activités dans des pays étrangers sensibles&amp;nbsp; Malaisie&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;22222 3 Activités dans des pays étrangers sensibles&amp;nbsp; Iraq&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;22222 2 Nature des opérations sensible&amp;nbsp; Lave-autos&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=have; by requestid criteriaid; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;set have; by requestId criteriaId;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;length all_criteria $64 my_criteria_final $80;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;retain all_criteria;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if first.criteriaId then call missing(all_criteria);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;all_criteria = catx(", ", all_criteria, criteria_value);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if last.criteriaId then do;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my_criteria_final = catx(": ", criteria, all_criteria);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;drop criteria criteria_value all_criteria;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=want noobs; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 18:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115073#M31822</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-08-19T18:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate and group by problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115074#M31823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;This code will get you started, however I don't have time now to think about how tor remove the extra commas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data = have out = temp;by requestid criteriaid criteria;&lt;/P&gt;&lt;P&gt;proc transpose data = temp out = temp2(drop = _NAME_ _LABEL_) prefix = criteria;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var criteria_value;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by requestid criteriaid criteria;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(keep = requestid criteriaid my_criteria_final );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set temp2;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp; temp_var = cat(compbl(criteria), ":", compbl(criteria_value));*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; my_criteria_final = cats(criteria, ":",criteria1,",",criteria2,",",criteria3);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;BR /&gt;Anca.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 18:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115074#M31823</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-08-19T18:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate and group by problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115075#M31824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both for your replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PGStats solution work as described.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nicnad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 20:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Concatenate-and-group-by-problem/m-p/115075#M31824</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-08-19T20:13:50Z</dc:date>
    </item>
  </channel>
</rss>

