<?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: Combining several row into one base on multiple cell values in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416709#M26818</link>
    <description>&lt;P&gt;Per your given example, you could just output last.jobno based on grouping by those 6 varaibles.&amp;nbsp; I assume however that your data could have 1 then , e.g. result could be 1 then 0?&amp;nbsp; If so then you need to be clear about what your rules are.&amp;nbsp; What if multiple records contain 1, should it still be one?&amp;nbsp; If so something like:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select     MONTH,
             FG,
             IMPORTER,
             DEALER,
             REFNO,
             JOB_NO,
             case when sum(RESULT1) &amp;gt; 0 then 1 else 0 end as RESULT1,
             case when sum(RESULT2) &amp;gt; 0 then 1 else 0 end as RESULT2,
             case when sum(RESULT3) &amp;gt; 0 then 1 else 0 end as RESULT3,
             case when sum(RESULT4) &amp;gt; 0 then 1 else 0 end as RESULT4,
             case when sum(RESULT5) &amp;gt; 0 then 1 else 0 end as RESULT5
  from       HAVE
  group by   MONTH,FG,IMPORTER,DEALER,REFNO,JOB_NO;
quit;
&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Nov 2017 15:09:24 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-28T15:09:24Z</dc:date>
    <item>
      <title>Combining several row into one base on multiple cell values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416705#M26817</link>
      <description>&lt;P&gt;hello everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;would like to get your guidance regarding how to put a code via SASprogram, to achieve below purpose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;FG&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Importer&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Dealer&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Refno&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Job Number&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Result 1&lt;/TD&gt;&lt;TD&gt;Result 2&lt;/TD&gt;&lt;TD&gt;Result 3&lt;/TD&gt;&lt;TD&gt;Result 4&lt;/TD&gt;&lt;TD&gt;Result 5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2015-07&lt;/TD&gt;&lt;TD&gt;4313&lt;/TD&gt;&lt;TD&gt;5959&lt;/TD&gt;&lt;TD&gt;2100&lt;/TD&gt;&lt;TD&gt;101540&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2015-07&lt;/TD&gt;&lt;TD&gt;4313&lt;/TD&gt;&lt;TD&gt;5959&lt;/TD&gt;&lt;TD&gt;2100&lt;/TD&gt;&lt;TD&gt;101540&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want above 2 rows combine into one row if first 6 column data is same, then last 5 column figure should be combined as well with multi result (for example "result 4", one row is 0, the other is 1, then combined result should be 0).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;would it be ok to provide your guidance?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 14:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416705#M26817</guid>
      <dc:creator>xiaoyao026</dc:creator>
      <dc:date>2017-11-28T14:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Combining several row into one base on multiple cell values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416709#M26818</link>
      <description>&lt;P&gt;Per your given example, you could just output last.jobno based on grouping by those 6 varaibles.&amp;nbsp; I assume however that your data could have 1 then , e.g. result could be 1 then 0?&amp;nbsp; If so then you need to be clear about what your rules are.&amp;nbsp; What if multiple records contain 1, should it still be one?&amp;nbsp; If so something like:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select     MONTH,
             FG,
             IMPORTER,
             DEALER,
             REFNO,
             JOB_NO,
             case when sum(RESULT1) &amp;gt; 0 then 1 else 0 end as RESULT1,
             case when sum(RESULT2) &amp;gt; 0 then 1 else 0 end as RESULT2,
             case when sum(RESULT3) &amp;gt; 0 then 1 else 0 end as RESULT3,
             case when sum(RESULT4) &amp;gt; 0 then 1 else 0 end as RESULT4,
             case when sum(RESULT5) &amp;gt; 0 then 1 else 0 end as RESULT5
  from       HAVE
  group by   MONTH,FG,IMPORTER,DEALER,REFNO,JOB_NO;
quit;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Nov 2017 15:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416709#M26818</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-28T15:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Combining several row into one base on multiple cell values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416711#M26819</link>
      <description>&lt;P&gt;To answer this question you will need to provide the structure your current data has.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best is to provide example data in the form of a data step so we know exactly what type of variables you are working with and names and values. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 15:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416711#M26819</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-28T15:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Combining several row into one base on multiple cell values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416715#M26821</link>
      <description>&lt;P&gt;A very straightforward method ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's not already in order, sort your data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by month FG Importer Dealer Refno Job_Number;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then get the minimum value for each variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have;&lt;/P&gt;
&lt;P&gt;by month FG Importer Dealer Refno Job_Number;&lt;/P&gt;
&lt;P&gt;var result1-result5;&lt;/P&gt;
&lt;P&gt;output out=want (drop=_type_ _freq_) min=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 15:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416715#M26821</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-28T15:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Combining several row into one base on multiple cell values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416718#M26823</link>
      <description>&lt;P&gt;Sounds like you want to calculate the MIN() for the RESULTx variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary missing nway data=have ;
  class month fg importer dealer refno jobnumber ;
  var result1-result5 ;
  output out=want(drop=_type_ _freq_)  min= ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the data is sorted you can use BY instead of CLASS and it should save processing time.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 15:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Combining-several-row-into-one-base-on-multiple-cell-values/m-p/416718#M26823</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-28T15:19:53Z</dc:date>
    </item>
  </channel>
</rss>

