<?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: Get all values separated by comma in one row by id in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539007#M16625</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID    Marks;
cards;
1    25
1    30
2    75
2    98
;
data want;
set have;
by id;
retain want ;
length want $50;
if first.id then call missing(want);
want=catx(',',want,marks);
if last.id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Feb 2019 15:01:20 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-02-27T15:01:20Z</dc:date>
    <item>
      <title>Get all values separated by comma in one row by id</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539003#M16622</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; Marks&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 25&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; 75&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; 98&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want this:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp; Marks&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 25, 30&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; 75, 98&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for help&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 14:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539003#M16622</guid>
      <dc:creator>indox</dc:creator>
      <dc:date>2019-02-27T14:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get all values separated by comma in one row by id</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539004#M16623</link>
      <description>&lt;P&gt;Are you doing this for reporting purposes? Or for some other purpose? There are ways to do this, but it really depends on why you want the output to appear this way. Also, does it have to be a comma separating the marks, or can the marks be in separate columns? Are there always 2 marks per ID, or does the solution have to allow for three (or more) marks per ID?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 14:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539004#M16623</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-27T14:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get all values separated by comma in one row by id</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539006#M16624</link>
      <description>&lt;P&gt;Two ways:&lt;/P&gt;
&lt;PRE&gt;proc transpose data=have out=want prefix=col;
  by id;
  var marks;
run;

data want;
  set want;
  length result $200;
  result=catx(',',of col:);
run;&lt;/PRE&gt;
&lt;P&gt;Or:&lt;/P&gt;
&lt;PRE&gt;data want;
  length result $200;
  set have;
  retain result;
  by id;
  result=ifc(first.id,marks,catx(',',result,marks));
  if last.id then output;
run;&lt;/PRE&gt;
&lt;P&gt;Note, unless this is for a repeat, its never a good idea to keep multiple data items in one variable!!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 15:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539006#M16624</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-27T15:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Get all values separated by comma in one row by id</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539007#M16625</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID    Marks;
cards;
1    25
1    30
2    75
2    98
;
data want;
set have;
by id;
retain want ;
length want $50;
if first.id then call missing(want);
want=catx(',',want,marks);
if last.id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Feb 2019 15:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539007#M16625</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-27T15:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Get all values separated by comma in one row by id</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539013#M16626</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Two ways:&lt;/P&gt;
&lt;PRE&gt;proc transpose data=have out=want prefix=col;
  by id;
  var marks;
run;

data want;
  set want;
  length result $200;
  result=catx(',',of col:);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it really begs the question of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135569"&gt;@indox&lt;/a&gt;&amp;nbsp;, what are you going to do with the data in this form with commas separating different data values? Unless you have some very strict reporting requirements, I don't see this data transformation as useful in any way. Certainly, if you are going to do further analysis of this data in SAS, having commas separating the values is an unnecessary complication.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 15:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Get-all-values-separated-by-comma-in-one-row-by-id/m-p/539013#M16626</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-27T15:09:58Z</dc:date>
    </item>
  </channel>
</rss>

