<?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: macro list in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494264#M31844</link>
    <description>&lt;P&gt;Thanks to all. I am somewhat new to SAS. I will use the correction for now and consider &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205" target="_self"&gt;&lt;SPAN class="login-bold"&gt;novinosrin&lt;/SPAN&gt;&lt;/A&gt;'s suggestion for future.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Sep 2018 18:56:30 GMT</pubDate>
    <dc:creator>kfluegge</dc:creator>
    <dc:date>2018-09-10T18:56:30Z</dc:date>
    <item>
      <title>macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494225#M31836</link>
      <description>&lt;P&gt;Hello, I would like to write code that generates a variable equal to 1 if another variable equals a value in a macro list. I am using SAS EG 7.1 on 64-bit Win 7. The code I have is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let oldPN_ICD9 = '4800', '4801';

data &amp;amp;ADMISSION;
set &amp;amp;ADMISSION;
%if DIAG1 = oldPN_ICD9 %then PN_diag = 1;
%else PN_diag = 0;
run;&lt;/PRE&gt;&lt;P&gt;The error I receive is below:&lt;/P&gt;&lt;PRE&gt;ERROR: The %IF statement is not valid in open code.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 17:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494225#M31836</guid>
      <dc:creator>kfluegge</dc:creator>
      <dc:date>2018-09-10T17:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494227#M31837</link>
      <description>&lt;PRE&gt;data &amp;amp;ADMISSION;
set &amp;amp;ADMISSION; *having same name is a bad idea. Harder to debug;
if DIAG1  IN (&amp;amp;oldPN_ICD9) then PN_diag = 1;
else PN_diag = 0;
run;&lt;/PRE&gt;
&lt;P&gt;See modifications above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to have code that generates a variable so this should work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the use of ADMISSION in DATA and SET statements is not recommended. Its an easy way to get errors that are harder to debug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120373"&gt;@kfluegge&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, I would like to write code that generates a variable equal to 1 if another variable equals a value in a macro list. I am using SAS EG 7.1 on 64-bit Win 7. The code I have is below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let oldPN_ICD9 = '4800', '4801';

data &amp;amp;ADMISSION;
set &amp;amp;ADMISSION;
%if DIAG1 = oldPN_ICD9 %then PN_diag = 1;
%else PN_diag = 0;
run;&lt;/PRE&gt;
&lt;P&gt;The error I receive is below:&lt;/P&gt;
&lt;PRE&gt;ERROR: The %IF statement is not valid in open code.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 17:43:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494227#M31837</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-10T17:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494228#M31838</link>
      <description>&lt;P&gt;Drop the percent signs.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 17:44:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494228#M31838</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-09-10T17:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494229#M31839</link>
      <description>&lt;P&gt;like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let oldPN_ICD9 = '4800', '4801';&lt;BR /&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input var $;&lt;BR /&gt;cards;&lt;BR /&gt;4800&lt;BR /&gt;4801&lt;BR /&gt;4802&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;PN_diag =var in (&amp;amp;oldPN_ICD9);&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Sep 2018 17:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494229#M31839</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-10T17:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494231#M31840</link>
      <description>You should use &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; solution. It's slightly simpler and one less step which always makes things faster.</description>
      <pubDate>Mon, 10 Sep 2018 17:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494231#M31840</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-10T17:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494234#M31841</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, but to be fair, we have to take into consideration OP may not "yet" be aware of boolean expressions. had it been 5 years ago when i started really using SAS, I would have chose the explicit if then.&lt;/P&gt;
&lt;P&gt;So better to be safe than sorry in my opinion&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. start with if then&lt;/P&gt;
&lt;P&gt;2. then &lt;STRONG&gt;ifn&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;PN_diag =&lt;STRONG&gt;ifn&lt;/STRONG&gt;(var in (&amp;amp;oldPN_ICD9),1,0);&lt;/P&gt;
&lt;P&gt;3. boolean&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not trying to judge OP, just my 2 cents thought&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 17:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494234#M31841</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-10T17:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494242#M31842</link>
      <description>&lt;P&gt;Nope, I fully agree. I usually tailor my solutions to the OP's level as much as I can.&amp;nbsp;&lt;BR /&gt;In this case, it makes sense to show how to fix the code (my solution) and then an 'optimal' solution which would be yours.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IFN() is another option that I constantly forget about, it was introduced after I stopped programming daily &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 18:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494242#M31842</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-10T18:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494245#M31843</link>
      <description>&lt;P&gt;Absolutely. If i recall what i heard and if it's accurate, I vaguely remember there is gonna be a new category for newbie/learners or something along those lines .&amp;nbsp;That will make us regulars to have an idea of OPs background as we cater our solution to their needs. And then as OPs gradually move to next level, the solutions will also change. Fun all the way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 18:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494245#M31843</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-10T18:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: macro list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494264#M31844</link>
      <description>&lt;P&gt;Thanks to all. I am somewhat new to SAS. I will use the correction for now and consider &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205" target="_self"&gt;&lt;SPAN class="login-bold"&gt;novinosrin&lt;/SPAN&gt;&lt;/A&gt;'s suggestion for future.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 18:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/macro-list/m-p/494264#M31844</guid>
      <dc:creator>kfluegge</dc:creator>
      <dc:date>2018-09-10T18:56:30Z</dc:date>
    </item>
  </channel>
</rss>

