<?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: Part of code not working in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639564#M9030</link>
    <description>&lt;P&gt;You are missing an equal sign in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;if Type in (1,2) and FIRST.ID then Defn 'Y'; &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Apr 2020 19:31:45 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-04-13T19:31:45Z</dc:date>
    <item>
      <title>Part of code not working</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639560#M9029</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have; 
by ID Date Sport; 
keep ID Type Sport Date EventID Defn; 
&lt;FONT color="#0000FF"&gt;dd = 0&amp;lt;=intck('MONTH', lag(Date), Date) &amp;lt;6; 
if Type in (1,2) and FIRST.ID then Defn 'Y'; 
else if Type in (1,2) and dd &amp;lt; 6 then Defn = 'N';&lt;/FONT&gt; 
day = ifc(FIRST.Date, 'Y', 'N'); 
person = ifc(ID, 'Y', 'N'); 
spo = ifc(FIRST.Sport, 'Y', 'N'); 
if person = 'Y' and day = 'Y' and spo = 'Y' then Defn = 'Y'; else Defn = 'N'; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;CODE class=" language-sas"&gt;data have;&lt;BR /&gt;ID Type Sport Date EventID;&lt;BR /&gt;&lt;BR /&gt;12 1 Baseball 06JUN2018 8779&lt;BR /&gt;12 1 Baseball 20JUN2019 8452&lt;BR /&gt;29 4 Skiing 12JAN2018 5683&lt;BR /&gt;29 4 Snowboard 12JAN2018 5683&lt;BR /&gt;08 2 Basketball 20MAR2019 1689&lt;BR /&gt;58 3 Tennis 30AUG2017 2157&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above is the code and an example of the data. The blue part of the code isn't working properly. I'm not sure how to fix this.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 19:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639560#M9029</guid>
      <dc:creator>mar0000</dc:creator>
      <dc:date>2020-04-13T19:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Part of code not working</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639564#M9030</link>
      <description>&lt;P&gt;You are missing an equal sign in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;if Type in (1,2) and FIRST.ID then Defn 'Y'; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Apr 2020 19:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639564#M9030</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-13T19:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Part of code not working</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639566#M9031</link>
      <description>That part is actually in there, I just typed the whole code. The part that isn't working about the code is that it isn't giving me a 6 month difference between two events</description>
      <pubDate>Mon, 13 Apr 2020 19:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639566#M9031</guid>
      <dc:creator>mar0000</dc:creator>
      <dc:date>2020-04-13T19:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Part of code not working</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639568#M9032</link>
      <description>&lt;P&gt;The last two statements will set defn to a new value, erasing its value from earlier statements. Probably not what you want.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 19:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639568#M9032</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-13T19:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Part of code not working</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639569#M9033</link>
      <description>Am I able to make the last two statemements work in the first two statements?</description>
      <pubDate>Mon, 13 Apr 2020 19:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639569#M9033</guid>
      <dc:creator>mar0000</dc:creator>
      <dc:date>2020-04-13T19:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Part of code not working</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639573#M9034</link>
      <description>&lt;P&gt;Example starting data and what you expect the result to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you have two sets of code setting the same variable to a value then you would need to restructure all of that into a single block of if/then/else. If one part of the code needs multiple statements then enclose the group inside a DO/End block:&lt;/P&gt;
&lt;P&gt;else if &amp;lt;some condition&amp;gt; then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; statement;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; statement;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; statement;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 20:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Part-of-code-not-working/m-p/639573#M9034</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-13T20:04:29Z</dc:date>
    </item>
  </channel>
</rss>

