<?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: SAS Code to work with specific logic in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611263#M178123</link>
    <description>Hi S_Lassen,&lt;BR /&gt;&lt;BR /&gt;Thanks for your help, I have tried running the second part of the code but I get an error message: &lt;BR /&gt;&lt;BR /&gt;ERROR: There was 1 unclosed DO block&lt;BR /&gt;&lt;BR /&gt;Any idea what I need to do to resolve this please?</description>
    <pubDate>Thu, 12 Dec 2019 11:39:08 GMT</pubDate>
    <dc:creator>KC_16</dc:creator>
    <dc:date>2019-12-12T11:39:08Z</dc:date>
    <item>
      <title>SAS Code to work with specific logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611254#M178116</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some code if possible please to only return the data whereby the logic below is satisfied, any idea how I would write this code please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;Where we have a Duplicate '&lt;STRONG&gt;Cust_No&lt;/STRONG&gt;'&amp;nbsp;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;Where '&lt;STRONG&gt;TransAmount&lt;/STRONG&gt;' has changed (one record could show £10, the next record could show £20)&amp;nbsp;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;and '&lt;STRONG&gt;TransID&lt;/STRONG&gt;' has changed (one record could show 345, the next record could show 346).&amp;nbsp;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;Only looking at records that have change since 1st April 2019 ('&lt;STRONG&gt;Date_In'&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2019 11:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611254#M178116</guid>
      <dc:creator>KC_16</dc:creator>
      <dc:date>2019-12-12T11:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Code to work with specific logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611258#M178120</link>
      <description>&lt;P&gt;Sounds like you have a large transaction dataset from which you only want part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, first sort the part you want by Cust_No and TransID (or a date variable?):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=&amp;lt;large transaction table&amp;gt; out=temptrans;
  where Date_In&amp;gt;='01APR2019'd;
  by Cust_No TransID;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Next, split the table in first and following records:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temptrans1 temptrans2(rename=(TransID=nextTransID TransAmount=nextTransAmount));
  set temptrans;
  by Cust_No;
  if first.Cust_No then do;
    if not last.Cust_no then output temptrans1;
    end;
  else if last.Cust_No then
    output temptrans2;
  else do;
    output temptrans1 temptrans2;
run;     &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Finally, merge the two parts and check for differences:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge temptrans1 temptrans2;
  by Cust_No;
  if TransID^=nextTransID and TransAmount^=nextTransAmount;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 11:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611258#M178120</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-12-12T11:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Code to work with specific logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611263#M178123</link>
      <description>Hi S_Lassen,&lt;BR /&gt;&lt;BR /&gt;Thanks for your help, I have tried running the second part of the code but I get an error message: &lt;BR /&gt;&lt;BR /&gt;ERROR: There was 1 unclosed DO block&lt;BR /&gt;&lt;BR /&gt;Any idea what I need to do to resolve this please?</description>
      <pubDate>Thu, 12 Dec 2019 11:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611263#M178123</guid>
      <dc:creator>KC_16</dc:creator>
      <dc:date>2019-12-12T11:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Code to work with specific logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611270#M178128</link>
      <description>&lt;P&gt;Sorry, put a DO too many in. That is what happens when you do not supply sample data to test on. The second data step should have been&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temptrans1 temptrans2(rename=(TransID=nextTransID TransAmount=nextTransAmount));
  set temptrans;
  by Cust_No;
  if first.Cust_No then do;
    if not last.Cust_no then output temptrans1;
    end;
  else if last.Cust_No then
    output temptrans2;
  else
    output temptrans1 temptrans2;
run;     &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Dec 2019 12:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611270#M178128</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-12-12T12:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Code to work with specific logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611387#M178175</link>
      <description>Thank you for your help, much appreciated.</description>
      <pubDate>Thu, 12 Dec 2019 16:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Code-to-work-with-specific-logic/m-p/611387#M178175</guid>
      <dc:creator>KC_16</dc:creator>
      <dc:date>2019-12-12T16:53:16Z</dc:date>
    </item>
  </channel>
</rss>

