<?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 Use Rank in SAS in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795589#M32929</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;if first.patid then call missing(difference);
if difference = . or difference &amp;lt;= 180 then ep = 0;
ep + 1;&lt;/PRE&gt;&lt;P&gt;Here is the sample data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PatID.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FirstDayofService.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LastDayofService.&amp;nbsp; Difference Episode&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2015-10-31&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2015-10-31&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2016-05-14&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2016-05-14&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;196&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;578&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;3&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this sample data, I am calculating the difference between first day of service and next first day of service. If the difference is 0 or &amp;lt; 180 days then I am trying to add the same episode. Else Episode will increase by 1. For the first three rows highlighted in green, its working correctly. For the next two rows, highlighted in orange, it's not working correctly as its incorrectly showing episode as 1. It should take the episode based on previous episode value. i.e. 3 if the difference is less than 180. In this case the correct response for last two rows in episode column should be 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me out.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Feb 2022 03:45:23 GMT</pubDate>
    <dc:creator>chandan_mishra</dc:creator>
    <dc:date>2022-02-11T03:45:23Z</dc:date>
    <item>
      <title>Use Rank in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795589#M32929</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;if first.patid then call missing(difference);
if difference = . or difference &amp;lt;= 180 then ep = 0;
ep + 1;&lt;/PRE&gt;&lt;P&gt;Here is the sample data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PatID.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FirstDayofService.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LastDayofService.&amp;nbsp; Difference Episode&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2015-10-31&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2015-10-31&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;.&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2016-05-14&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2016-05-14&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;196&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;578&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#008000"&gt;3&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;AB1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;2017-12-13&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this sample data, I am calculating the difference between first day of service and next first day of service. If the difference is 0 or &amp;lt; 180 days then I am trying to add the same episode. Else Episode will increase by 1. For the first three rows highlighted in green, its working correctly. For the next two rows, highlighted in orange, it's not working correctly as its incorrectly showing episode as 1. It should take the episode based on previous episode value. i.e. 3 if the difference is less than 180. In this case the correct response for last two rows in episode column should be 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me out.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 03:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795589#M32929</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2022-02-11T03:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Use Rank in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795612#M32933</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;If the difference is 0 or &amp;lt; 180 days then I am trying to add the same episode.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Right know your code does the opposite:&lt;/P&gt;
&lt;PRE&gt;if difference = . or &lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;difference &amp;lt;= 180 then ep = 0&lt;/FONT&gt;&lt;/STRONG&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;A fix could be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.patid then do;
  difference = 0;
  ep = 0;
end;

if difference &amp;gt; 180 then ep +1;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Feb 2022 06:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795612#M32933</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-02-11T06:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Use Rank in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795665#M32939</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your response. When I use the fix below, I am getting the correct logic but not the correct result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chandan_mishra_0-1644588046225.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68391i3D31C4DF28D562ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="chandan_mishra_0-1644588046225.png" alt="chandan_mishra_0-1644588046225.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Episode should show 1,2,3,3,3, Here it is starting at 0.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried changing the initial value of episode to 1,&lt;/P&gt;&lt;PRE&gt;rsubmit;
data check1;
	set check;
	by FDS;/*First day of Service*/
if first.patid then do;
  difference = 0;
  episode = 1;
end;

if difference &amp;gt; 180 then episode +1;
run;
endrsubmit;&lt;/PRE&gt;&lt;P&gt;But even then its showing the same results.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 14:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795665#M32939</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2022-02-11T14:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Use Rank in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795666#M32940</link>
      <description>Sorry skip this previous message. Figured it out. Didnt add proc sort by patid and fds.&lt;BR /&gt;&lt;BR /&gt;rsubmit;&lt;BR /&gt;proc sort data=UASADHOC&lt;BR /&gt;out=check;&lt;BR /&gt;by PATID fds;&lt;BR /&gt;run;&lt;BR /&gt;endrsubmit;&lt;BR /&gt;&lt;BR /&gt;rsubmit;&lt;BR /&gt;data check1;&lt;BR /&gt;set check;&lt;BR /&gt;by PATID FDS;&lt;BR /&gt;if first.PatID then do;&lt;BR /&gt;difference = 0;&lt;BR /&gt;episode = 1;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;if difference &amp;gt; 180 then episode +1;&lt;BR /&gt;run;&lt;BR /&gt;endrsubmit;&lt;BR /&gt;&lt;BR /&gt;Its working now.</description>
      <pubDate>Fri, 11 Feb 2022 14:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Use-Rank-in-SAS/m-p/795666#M32940</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2022-02-11T14:09:41Z</dc:date>
    </item>
  </channel>
</rss>

