<?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: Tip for sas code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326877#M72876</link>
    <description>&lt;P&gt;Here's a reasonable approach:&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 client date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by client;&lt;/P&gt;
&lt;P&gt;days_lapsed = dif(date);&lt;/P&gt;
&lt;P&gt;prior_facility = lag(facility);&lt;/P&gt;
&lt;P&gt;if first.client=0 and days_lapsed &amp;lt; 30 and facility = prior_facility then event='Y';&lt;/P&gt;
&lt;P&gt;drop days_lapsed prior_facility;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that your date variable is actually a SAS date, not a character string.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 22:24:31 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-01-23T22:24:31Z</dc:date>
    <item>
      <title>Tip for sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326858#M72869</link>
      <description>&lt;P&gt;I have a dataset with the following columns: dates, client name, jail record, jail facility name&lt;/P&gt;&lt;P&gt;I need to query the data in base sas as follow:&lt;/P&gt;&lt;P&gt;If a client has a jail record and there is a previous jail record within 30 days where the jail facility was different then i want to code it as an event for each client.&lt;/P&gt;&lt;P&gt;Any ideas how to do that please!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 21:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326858#M72869</guid>
      <dc:creator>Lordy</dc:creator>
      <dc:date>2017-01-23T21:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Tip for sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326877#M72876</link>
      <description>&lt;P&gt;Here's a reasonable approach:&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 client date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by client;&lt;/P&gt;
&lt;P&gt;days_lapsed = dif(date);&lt;/P&gt;
&lt;P&gt;prior_facility = lag(facility);&lt;/P&gt;
&lt;P&gt;if first.client=0 and days_lapsed &amp;lt; 30 and facility = prior_facility then event='Y';&lt;/P&gt;
&lt;P&gt;drop days_lapsed prior_facility;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that your date variable is actually a SAS date, not a character string.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 22:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326877#M72876</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-23T22:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Tip for sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326878#M72877</link>
      <description>&lt;P&gt;Sort by client name and date. Then you can use the lag() function to compare variables with values from the preceding observation.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 22:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326878#M72877</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-23T22:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Tip for sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326884#M72880</link>
      <description>&lt;P&gt;Do you have some id such as SSN? Note that people involved in jail often have a good reason to hide their real identity and multiple arrests and/or convictions and a simple name match is likely to be&amp;nbsp;insufficient. Also is Rob Smith the same as Robert Smith or Bob Smith?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 22:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/326884#M72880</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-23T22:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Tip for sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/327154#M72961</link>
      <description>Thanks - I will use this approach.&lt;BR /&gt;</description>
      <pubDate>Tue, 24 Jan 2017 19:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tip-for-sas-code/m-p/327154#M72961</guid>
      <dc:creator>Lordy</dc:creator>
      <dc:date>2017-01-24T19:28:51Z</dc:date>
    </item>
  </channel>
</rss>

