<?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: convert observations in to 1 row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/747270#M234512</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt; thanks, would like to understand 7th line from your code with reference to the previous line. how in the code pageList is able to concatenate the 1st row PAGE value with other rows when we've made the first.pageList variable=missing (in the 6th line of your code). To me, I used to think 7th line will work when we place the 7th line with a  then do;end; statement.   &lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; your comment will be highly appreciated.</description>
    <pubDate>Fri, 11 Jun 2021 05:13:43 GMT</pubDate>
    <dc:creator>sahoositaram555</dc:creator>
    <dc:date>2021-06-11T05:13:43Z</dc:date>
    <item>
      <title>convert observations in to 1 row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/746957#M234400</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have a dataset as below(sample provided).&lt;/P&gt;
&lt;P&gt;data abc;&lt;BR /&gt;variable="COVAL1";page=3;output;&lt;BR /&gt;variable="COVAL1";page=4;output;&lt;BR /&gt;variable="COVAL1";page=5;output;&lt;BR /&gt;variable="COVAL1";page=6;output;&lt;BR /&gt;variable="COVAL2";page=13;output;&lt;BR /&gt;variable="COVAL2";page=14;output;&lt;BR /&gt;variable="COVAL2";page=15;output;&lt;BR /&gt;variable="COVAL2";page=16;output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to generate a new dataset where the result should appear as below.&lt;/P&gt;
&lt;P&gt;coval1&amp;nbsp; 3,4,5,6&amp;nbsp;&lt;/P&gt;
&lt;P&gt;coval2&amp;nbsp; 13,14 ,15,16&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The goal is to filter observations from the abc dataset where for similar observations in multiple rows should be filtered and then convert the structure in to a way such as for 1 row per variable name must be created with page numbers&amp;nbsp; must appear in 1 row with all the pages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please guide us how to proceed for a solution for the same.&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;</description>
      <pubDate>Thu, 10 Jun 2021 08:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/746957#M234400</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2021-06-10T08:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: convert observations in to 1 row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/746982#M234408</link>
      <description>&lt;P&gt;I don't see the need to merge data into a list that will be hardly useful, but here you go&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set work.abc;
   by variable /* notsorted */;
   
   length pageList $ 100;
   retain pageList;
   
   if first.variable then pageList = ' ';
   
   pageList = catx(',', pageList, page);
   
   if last.variable then output;
   
   drop page;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Jun 2021 10:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/746982#M234408</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-06-10T10:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: convert observations in to 1 row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/747270#M234512</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt; thanks, would like to understand 7th line from your code with reference to the previous line. how in the code pageList is able to concatenate the 1st row PAGE value with other rows when we've made the first.pageList variable=missing (in the 6th line of your code). To me, I used to think 7th line will work when we place the 7th line with a  then do;end; statement.   &lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; your comment will be highly appreciated.</description>
      <pubDate>Fri, 11 Jun 2021 05:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/747270#M234512</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2021-06-11T05:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: convert observations in to 1 row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/747272#M234513</link>
      <description>&lt;P&gt;To bad that the community software does not put line numbers to code-boxes ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The retain-statement prevents "pageList" to be automatically set to missing when the pdv is populated during set-statement. Whenever a new value of "variable" is encountered, the value of "pageList" needs to be reset to missing.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 05:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-observations-in-to-1-row/m-p/747272#M234513</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-06-11T05:25:50Z</dc:date>
    </item>
  </channel>
</rss>

