<?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: Uninitialized var in macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Uninitialized-var-in-macro/m-p/203640#M37944</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Tom!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jun 2015 15:25:50 GMT</pubDate>
    <dc:creator>kec3814</dc:creator>
    <dc:date>2015-06-12T15:25:50Z</dc:date>
    <item>
      <title>Uninitialized var in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Uninitialized-var-in-macro/m-p/203638#M37942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm writing a macro where it creates date flags for different variables in my dataset. Some of the variables have an associated year variable (var_YYYY) and some don't. So in my call, I add another parameter to note if there is a year variable (yrvar= 1 or 2). I then wrote an if/then/do statement that is supposed to only perform the data step if yrvar is 1 or 2. But when I run the first call, even though yrvar has a value of 2, I still get the&amp;nbsp; note saying EN_&amp;amp;var2._YYYY is uninitialized. Why is it even performing the task in red if yrvar=2 in the call?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro days(var1,var2,res,yrvar);&lt;BR /&gt;data dates2;&lt;BR /&gt; set dates;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; where EN_&amp;amp;var1. in (&amp;amp;res.);&lt;BR /&gt; if EN_&amp;amp;var2._MM in (1,2,3,4,5,6,7,8,9,10,11,12) then EN_&amp;amp;var1._MOFLAG=1; else EN_&amp;amp;var1._MOFLAG=0; **month y/n**;&lt;BR /&gt; &lt;BR /&gt; if &amp;amp;yrvar. = 1 then do;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; if EN_&amp;amp;var2._YYYY in (2010,2011,2012) then EN_&amp;amp;var1._YRFLAG=1; else EN_&amp;amp;var1._YRFLAG=0; **year y/n**;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; if EN_&amp;amp;var1._MOFLAG=1 and EN_&amp;amp;var1._YRFLAG=1 then EN_&amp;amp;var1._SDFLAG=1;&amp;nbsp; else EN_&amp;amp;var1._SDFLAG=0; **start date y/n**;&lt;/SPAN&gt;&lt;BR /&gt; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; else if &amp;amp;yrvar. = 2 then do;&lt;BR /&gt; if EN_&amp;amp;var1._MOFLAG=1 then EN_&amp;amp;var1._SDFLAG=1;&amp;nbsp; else EN_&amp;amp;var1._SDFLAG=0; **start date y/n**;&lt;BR /&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend days;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%days(B9A1_YN,B9A2B,1,2);&lt;BR /&gt;%days(B9A6C_YN,B9A6D2,1,1); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 15:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Uninitialized-var-in-macro/m-p/203638#M37942</guid>
      <dc:creator>kec3814</dc:creator>
      <dc:date>2015-06-11T15:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Uninitialized var in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Uninitialized-var-in-macro/m-p/203639#M37943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You wrote a DATA step IF statement.&amp;nbsp; That will prevent the data step from executing those lines of code, but NOT from the lines of code existing and causing reference to the variable names from being seen when SAS compiles the data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use %IF %THEN %DO: .... %END: in your macro to have the MACRO conditionally generate the lines of code.&amp;nbsp; Then the data step will not have those lines at all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 17:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Uninitialized-var-in-macro/m-p/203639#M37943</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-06-11T17:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Uninitialized var in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Uninitialized-var-in-macro/m-p/203640#M37944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Tom!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 15:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Uninitialized-var-in-macro/m-p/203640#M37944</guid>
      <dc:creator>kec3814</dc:creator>
      <dc:date>2015-06-12T15:25:50Z</dc:date>
    </item>
  </channel>
</rss>

