<?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 Finding accounts which have been at least once in a category and are still in the same category in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861059#M38035</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Task is to find the all the debt_code (account number) which have been at least once in 133 repcode in the last one year and if they are still in the same repcode. For this, I first found the debt_code in 133 repcode. Then I found where the previous repcode was 133 in last one year. But I am not sure how to approach to find debt_code which have been in 133 and are still in 133. Can you guide what is the best way to get the solutions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Accounts_In_133 AS
Select rep_code,
debt_code
From p2scflow.debt
Where rep_code LIKE '133';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Feb 2023 11:49:13 GMT</pubDate>
    <dc:creator>Sandeep77</dc:creator>
    <dc:date>2023-02-27T11:49:13Z</dc:date>
    <item>
      <title>Finding accounts which have been at least once in a category and are still in the same category</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861059#M38035</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Task is to find the all the debt_code (account number) which have been at least once in 133 repcode in the last one year and if they are still in the same repcode. For this, I first found the debt_code in 133 repcode. Then I found where the previous repcode was 133 in last one year. But I am not sure how to approach to find debt_code which have been in 133 and are still in 133. Can you guide what is the best way to get the solutions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Accounts_In_133 AS
Select rep_code,
debt_code
From p2scflow.debt
Where rep_code LIKE '133';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Feb 2023 11:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861059#M38035</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-02-27T11:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Finding accounts which have been at least once in a category and are still in the same category</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861061#M38037</link>
      <description>&lt;P&gt;Can you provide some example data that resembles your problem? Makes it much easier to provide a usable code answer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 11:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861061#M38037</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-02-27T11:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding accounts which have been at least once in a category and are still in the same category</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861062#M38038</link>
      <description>&lt;P&gt;Below is the data for accounts in 133 repcode. It shows the repcode and debt_code. I am not sure how to approach further to find if the debt_code have been in 133 in the last year and if those debt_code are still in 133?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Accounts_In_133;&lt;BR /&gt;input rep_code :$4. debt_code :$9.;&lt;BR /&gt;datalines;&lt;BR /&gt;133 261094882&lt;BR /&gt;133 261138333&lt;BR /&gt;133 261149033&lt;BR /&gt;133 261185011&lt;BR /&gt;133 382118339&lt;BR /&gt;133 292320751&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 11:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861062#M38038</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-02-27T11:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding accounts which have been at least once in a category and are still in the same category</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861071#M38039</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Task is to find the all the debt_code (account number) which have been at least once in 133 repcode in the last one year and if they are still in the same repcode."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Any repcode that's currently in 133 also meets the requirement of have been at least once in 133.&lt;/P&gt;
&lt;P&gt;If the requirement really is as you formulated it then you just need to check if the latest repcode for a specific debt_code is 133.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your sample data is missing the date column - but let's assume there is a date column called dt then the SQL could look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table accounts_in_133 as
    select 
      debt_code
      ,max(dt) as latest_dt format=date9.
    from p2scflow.debt
    where rep_code='133'
    group by
      debt_code
    having max(dt)=dt
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 12:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-accounts-which-have-been-at-least-once-in-a-category-and/m-p/861071#M38039</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-02-27T12:19:55Z</dc:date>
    </item>
  </channel>
</rss>

