<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505758#M135475</link>
    <description>Did not work - code still flagging sunday</description>
    <pubDate>Thu, 18 Oct 2018 20:34:07 GMT</pubDate>
    <dc:creator>Lordy</dc:creator>
    <dc:date>2018-10-18T20:34:07Z</dc:date>
    <item>
      <title>sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505651#M135439</link>
      <description>&lt;P&gt;I have a data containing names, SSN, date of service, and oranges as column names. Each person is to receive one orange&amp;nbsp;within a week, i.e.&amp;nbsp;any day from sunday to saturday.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;need help with a sas code to flag all SSN that received more than one orange within the specified one week period. The code below is flagging those who received oranges on sunday as well, however, any sunday is the first day of the week. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&amp;nbsp;mydata;&lt;/P&gt;&lt;P&gt;by SSN date;&lt;/P&gt;&lt;P&gt;days_passed=dif(date);&lt;/P&gt;&lt;P&gt;if SSN=&lt;STRONG&gt;0&lt;/STRONG&gt; and &lt;SPAN&gt;days_passed&lt;/SPAN&gt; in (1,2,3,4,5,6) then event=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;drop days_passed&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 17:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505651#M135439</guid>
      <dc:creator>Lordy</dc:creator>
      <dc:date>2018-10-18T17:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505658#M135443</link>
      <description>&lt;P&gt;You want to do something different for the first value of each SSN, assuming your data is sorted by SSN and date.&lt;/P&gt;
&lt;P&gt;Perhaps:&lt;/P&gt;
&lt;PRE&gt;data mydata;
   by SSN date;
   days_passed=dif(date);
   if first.ssn then event=0;
   else if days_passed in (1,2,3,4,5,6) then event=1;
   drop days_passed;
run;
&lt;/PRE&gt;
&lt;P&gt;But without seeing some actual values it might be hard to guess what exact code you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 17:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505658#M135443</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-18T17:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505758#M135475</link>
      <description>Did not work - code still flagging sunday</description>
      <pubDate>Thu, 18 Oct 2018 20:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505758#M135475</guid>
      <dc:creator>Lordy</dc:creator>
      <dc:date>2018-10-18T20:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505764#M135479</link>
      <description>&lt;P&gt;If the goal is to check by calendar week then try using INTNX() function with week interval.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  by SSN date;
  week=intnx('week',date,0,'b');
  if first.ssn then n_orange=0;
  if week ne lag(week) then n_orange=0;
  n_orange+1;
  event=(n_orange&amp;gt;1) ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 20:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505764#M135479</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-18T20:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505798#M135494</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71425"&gt;@Lordy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Did not work - code still flagging sunday&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Provide actual example starting data and the desired output for a few records.&lt;/P&gt;
&lt;P&gt;We're kind of flying blind as to your actual values and what the actual result should look like. We can't even be sure whether your "date" actually is a date or not.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 23:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/505798#M135494</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-18T23:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/506679#M135819</link>
      <description>&lt;P&gt;Worked!&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 21:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-code/m-p/506679#M135819</guid>
      <dc:creator>Lordy</dc:creator>
      <dc:date>2018-10-22T21:27:56Z</dc:date>
    </item>
  </channel>
</rss>

