<?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 Unable to resolve a nested macro variable inside a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622899#M183261</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to strip off data before 01-Nov-2019 from all the Raw datasets and I am trying to write a macro for the same. I am calling a macro within a macro as first I need to build up my date from Raw Date variables - 'Day','Month' and 'Year'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The whole code is working fine except for variable &amp;amp;&amp;amp;out is not resolving to the actual date value - but is instead resolving to AUDAT_.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would much appreciable!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro strip_dt(yy, mm, dd, out,ds);&lt;/P&gt;&lt;P&gt;proc sort data=ole.&amp;amp;ds(encoding=asciiany) out=&amp;amp;ds.1; by subject;&lt;/P&gt;&lt;P&gt;data &amp;amp;ds.2 ;&lt;BR /&gt;set &amp;amp;ds.1;&lt;/P&gt;&lt;P&gt;if &amp;amp;yy ne . and &amp;amp;mm ne . and &amp;amp;dd ne . then&lt;BR /&gt;&amp;amp;out=strip(put(&amp;amp;yy,best.))||'-'||strip(put(&amp;amp;mm,z2.))||'-'||strip(put(&amp;amp;dd,z2.));&lt;BR /&gt;else if &amp;amp;yy ne . and &amp;amp;mm ne . and &amp;amp;dd eq . then&lt;BR /&gt;&amp;amp;out=strip(put(&amp;amp;yy,best.))||'-'||strip(put(&amp;amp;mm,z2.));&lt;BR /&gt;else if &amp;amp;yy ne . and &amp;amp;mm eq . and &amp;amp;dd eq . then&lt;BR /&gt;&amp;amp;out=strip(put(&amp;amp;yy,best.));&lt;/P&gt;&lt;P&gt;if &amp;amp;&amp;amp;out &amp;lt;='2019-11-01' then&lt;BR /&gt;flag='yes';&lt;BR /&gt;else flag='No';&lt;BR /&gt;if flag='yes' then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend strip_dt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%strip_dt(AUDAT_YYYY, AUDAT_MM, AUDAT_DD,AUDAT_,auxo);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2020 23:39:58 GMT</pubDate>
    <dc:creator>PA8</dc:creator>
    <dc:date>2020-02-06T23:39:58Z</dc:date>
    <item>
      <title>Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622899#M183261</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to strip off data before 01-Nov-2019 from all the Raw datasets and I am trying to write a macro for the same. I am calling a macro within a macro as first I need to build up my date from Raw Date variables - 'Day','Month' and 'Year'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The whole code is working fine except for variable &amp;amp;&amp;amp;out is not resolving to the actual date value - but is instead resolving to AUDAT_.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would much appreciable!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro strip_dt(yy, mm, dd, out,ds);&lt;/P&gt;&lt;P&gt;proc sort data=ole.&amp;amp;ds(encoding=asciiany) out=&amp;amp;ds.1; by subject;&lt;/P&gt;&lt;P&gt;data &amp;amp;ds.2 ;&lt;BR /&gt;set &amp;amp;ds.1;&lt;/P&gt;&lt;P&gt;if &amp;amp;yy ne . and &amp;amp;mm ne . and &amp;amp;dd ne . then&lt;BR /&gt;&amp;amp;out=strip(put(&amp;amp;yy,best.))||'-'||strip(put(&amp;amp;mm,z2.))||'-'||strip(put(&amp;amp;dd,z2.));&lt;BR /&gt;else if &amp;amp;yy ne . and &amp;amp;mm ne . and &amp;amp;dd eq . then&lt;BR /&gt;&amp;amp;out=strip(put(&amp;amp;yy,best.))||'-'||strip(put(&amp;amp;mm,z2.));&lt;BR /&gt;else if &amp;amp;yy ne . and &amp;amp;mm eq . and &amp;amp;dd eq . then&lt;BR /&gt;&amp;amp;out=strip(put(&amp;amp;yy,best.));&lt;/P&gt;&lt;P&gt;if &amp;amp;&amp;amp;out &amp;lt;='2019-11-01' then&lt;BR /&gt;flag='yes';&lt;BR /&gt;else flag='No';&lt;BR /&gt;if flag='yes' then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend strip_dt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%strip_dt(AUDAT_YYYY, AUDAT_MM, AUDAT_DD,AUDAT_,auxo);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 23:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622899#M183261</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-06T23:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622900#M183262</link>
      <description>&lt;P&gt;At the top of your program, insert this command and then run it again&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint symbolgen mlogic;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then show us the log of the part where you run this data step. Please, in order so that the log is formatted properly, which makes it much more readable to us; please copy the appropriate part of the log as text and paste it into the window that appears when you click on the {i}. DO NOT SKIP THIS STEP. If you don't follow this procedure, we will simply ask again that you follow this procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I need to strip off data before 01-Nov-2019 from all the Raw datasets&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, please give us an example of what you are trying to do here.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 23:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622900#M183262</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-06T23:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622904#M183264</link>
      <description>&lt;P&gt;thank you so much for the prompt helpI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had included the options as stated but missed to include the log. Please find the same attached :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;17801&lt;BR /&gt;17802 dm 'log' clear;&lt;BR /&gt;17803 options mprint symbolgen mlogic;&lt;/P&gt;&lt;P&gt;17804&lt;BR /&gt;17805 %macro strip_dt(yy, mm, dd, out,ds);&lt;BR /&gt;17806&lt;BR /&gt;17807 proc sort data=ole.&amp;amp;ds(encoding=asciiany) out=&amp;amp;ds.1; by subject;&lt;BR /&gt;17808&lt;BR /&gt;17809 data &amp;amp;ds.2 ;&lt;BR /&gt;17810 set &amp;amp;ds.1;&lt;BR /&gt;17811&lt;BR /&gt;17812 if &amp;amp;yy ne . and &amp;amp;mm ne . and &amp;amp;dd ne . then&lt;BR /&gt;17813 &amp;amp;out=strip(put(&amp;amp;yy,best.))||'-'||strip(put(&amp;amp;mm,z2.))||'-'||strip(put(&amp;amp;dd,z2.));&lt;BR /&gt;17814 else if &amp;amp;yy ne . and &amp;amp;mm ne . and &amp;amp;dd eq . then&lt;BR /&gt;17815 &amp;amp;out=strip(put(&amp;amp;yy,best.))||'-'||strip(put(&amp;amp;mm,z2.));&lt;BR /&gt;17816 else if &amp;amp;yy ne . and &amp;amp;mm eq . and &amp;amp;dd eq . then&lt;BR /&gt;17817 &amp;amp;out=strip(put(&amp;amp;yy,best.));&lt;BR /&gt;17818&lt;BR /&gt;17819 if &amp;amp;&amp;amp;out &amp;lt;='2019-11-01' then&lt;BR /&gt;17820 flag='yes';&lt;BR /&gt;17821 else flag='No';&lt;BR /&gt;17822 if flag='yes' then output;&lt;BR /&gt;17823 run;&lt;BR /&gt;17824&lt;BR /&gt;17825 %mend strip_dt;&lt;BR /&gt;17826 run;&lt;BR /&gt;17827&lt;BR /&gt;17828 %strip_dt(AUDAT_YYYY, AUDAT_MM, AUDAT_DD,AUDAT_,auxo);&lt;BR /&gt;MLOGIC(STRIP_DT): Beginning execution.&lt;BR /&gt;MLOGIC(STRIP_DT): Parameter YY has value AUDAT_YYYY&lt;BR /&gt;MLOGIC(STRIP_DT): Parameter MM has value AUDAT_MM&lt;BR /&gt;MLOGIC(STRIP_DT): Parameter DD has value AUDAT_DD&lt;BR /&gt;MLOGIC(STRIP_DT): Parameter OUT has value AUDAT_&lt;BR /&gt;MLOGIC(STRIP_DT): Parameter DS has value auxo&lt;BR /&gt;SYMBOLGEN: Macro variable DS resolves to auxo&lt;BR /&gt;SYMBOLGEN: Macro variable DS resolves to auxo&lt;BR /&gt;MPRINT(STRIP_DT): proc sort data=ole.auxo(encoding=asciiany) out=auxo1;&lt;BR /&gt;MPRINT(STRIP_DT): by subject;&lt;BR /&gt;SYMBOLGEN: Macro variable DS resolves to auxo&lt;BR /&gt;NOTE: There were 1272 observations read from the data set OLE.AUXO.&lt;BR /&gt;NOTE: The data set WORK.AUXO1 has 1272 observations and 44 variables.&lt;BR /&gt;NOTE: Compressing data set WORK.AUXO1 decreased size by 90.63 percent.&lt;BR /&gt;Compressed is 3 pages; un-compressed would require 32 pages.&lt;BR /&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;BR /&gt;real time 0.56 seconds&lt;BR /&gt;user cpu time 0.04 seconds&lt;BR /&gt;system cpu time 0.04 seconds&lt;BR /&gt;memory 8689.59k&lt;BR /&gt;OS Memory 54000.00k&lt;BR /&gt;Timestamp 02/06/2020 06:44:33 PM&lt;BR /&gt;Step Count 1169 Switch Count 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;MPRINT(STRIP_DT): data auxo2 ;&lt;BR /&gt;SYMBOLGEN: Macro variable DS resolves to auxo&lt;BR /&gt;MPRINT(STRIP_DT): set auxo1;&lt;BR /&gt;SYMBOLGEN: Macro variable YY resolves to AUDAT_YYYY&lt;BR /&gt;SYMBOLGEN: Macro variable MM resolves to AUDAT_MM&lt;BR /&gt;SYMBOLGEN: Macro variable DD resolves to AUDAT_DD&lt;BR /&gt;SYMBOLGEN: Macro variable OUT resolves to AUDAT_&lt;BR /&gt;SYMBOLGEN: Macro variable YY resolves to AUDAT_YYYY&lt;BR /&gt;SYMBOLGEN: Macro variable MM resolves to AUDAT_MM&lt;BR /&gt;SYMBOLGEN: Macro variable DD resolves to AUDAT_DD&lt;BR /&gt;MPRINT(STRIP_DT): if AUDAT_YYYY ne . and AUDAT_MM ne . and AUDAT_DD ne . then&lt;BR /&gt;AUDAT_=strip(put(AUDAT_YYYY,best.))||'-'||strip(put(AUDAT_MM,z2.))||'-'||strip(put(AUDAT_DD,z2.));&lt;BR /&gt;SYMBOLGEN: Macro variable YY resolves to AUDAT_YYYY&lt;BR /&gt;SYMBOLGEN: Macro variable MM resolves to AUDAT_MM&lt;BR /&gt;SYMBOLGEN: Macro variable DD resolves to AUDAT_DD&lt;BR /&gt;SYMBOLGEN: Macro variable OUT resolves to AUDAT_&lt;BR /&gt;SYMBOLGEN: Macro variable YY resolves to AUDAT_YYYY&lt;BR /&gt;SYMBOLGEN: Macro variable MM resolves to AUDAT_MM&lt;BR /&gt;MPRINT(STRIP_DT): else if AUDAT_YYYY ne . and AUDAT_MM ne . and AUDAT_DD eq . then&lt;BR /&gt;AUDAT_=strip(put(AUDAT_YYYY,best.))||'-'||strip(put(AUDAT_MM,z2.));&lt;BR /&gt;SYMBOLGEN: Macro variable YY resolves to AUDAT_YYYY&lt;BR /&gt;SYMBOLGEN: Macro variable MM resolves to AUDAT_MM&lt;BR /&gt;SYMBOLGEN: Macro variable DD resolves to AUDAT_DD&lt;BR /&gt;SYMBOLGEN: Macro variable OUT resolves to AUDAT_&lt;BR /&gt;SYMBOLGEN: Macro variable YY resolves to AUDAT_YYYY&lt;BR /&gt;MPRINT(STRIP_DT): else if AUDAT_YYYY ne . and AUDAT_MM eq . and AUDAT_DD eq . then&lt;BR /&gt;AUDAT_=strip(put(AUDAT_YYYY,best.));&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable&lt;FONT color="#FF0000"&gt; &lt;STRONG&gt;OUT resolves to AUDAT_&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;MPRINT(STRIP_DT): if&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; AUDAT_&lt;/STRONG&gt; &lt;/FONT&gt;&amp;lt;='2019-11-01' then flag='yes';&lt;BR /&gt;MPRINT(STRIP_DT): else flag='No';&lt;BR /&gt;MPRINT(STRIP_DT): if flag='yes' then output;&lt;BR /&gt;MPRINT(STRIP_DT): run;&lt;/P&gt;&lt;P&gt;NOTE: There were 1272 observations read from the data set WORK.AUXO1.&lt;BR /&gt;NOTE: The data set WORK.AUXO2 has 1272 observations and 46 variables.&lt;BR /&gt;NOTE: Compressing data set WORK.AUXO2 decreased size by 90.63 percent.&lt;BR /&gt;Compressed is 3 pages; un-compressed would require 32 pages.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.06 seconds&lt;BR /&gt;user cpu time 0.03 seconds&lt;BR /&gt;system cpu time 0.03 seconds&lt;BR /&gt;memory 1441.43k&lt;BR /&gt;OS Memory 46672.00k&lt;BR /&gt;Timestamp 02/06/2020 06:44:34 PM&lt;BR /&gt;Step Count 1170 Switch Count 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;MLOGIC(STRIP_DT): Ending execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 23:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622904#M183264</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-06T23:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622905#M183265</link>
      <description>&lt;P&gt;The variable highlighted in Red color is not resolved to date value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, the intent is to consider only data on or prior to 01-Nov-2019 from all the Raw datasets.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 23:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622905#M183265</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-06T23:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622907#M183267</link>
      <description>&lt;P&gt;Please, in order so that the log is formatted properly, which makes it much more readable to us; please copy the appropriate part of the log as text and paste it into the window that appears when you click on the {i}. DO NOT SKIP THIS STEP. If you don't follow this procedure, we will simply ask again that you follow this procedure.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 23:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622907#M183267</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-06T23:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622909#M183268</link>
      <description>&lt;PRE&gt;SYMBOLGEN:  Macro variable YY resolves to AUDAT_YYYY
SYMBOLGEN:  Macro variable MM resolves to AUDAT_MM
SYMBOLGEN:  Macro variable DD resolves to AUDAT_DD
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
SYMBOLGEN:  Macro variable YY resolves to AUDAT_YYYY
MPRINT(STRIP_DT):   else if AUDAT_YYYY ne . and AUDAT_MM eq . and AUDAT_DD eq . then
AUDAT_=strip(put(AUDAT_YYYY,best.));
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable &lt;FONT color="#0000FF"&gt;OUT resolves to AUDAT_&lt;/FONT&gt;
MPRINT(STRIP_DT):   if &lt;FONT color="#0000FF"&gt;AUDAT_&lt;/FONT&gt; &amp;lt;='2019-11-01' then flag='yes';
MPRINT(STRIP_DT):   else flag='No';
MPRINT(STRIP_DT):   if flag='yes' then output;
MPRINT(STRIP_DT):   run;

NOTE: There were 1272 observations read from the data set WORK.AUXO1.
NOTE: The data set WORK.AUXO2 has 1272 observations and 46 variables.
NOTE: Compressing data set WORK.AUXO2 decreased size by 90.63 percent.
      Compressed is 3 pages; un-compressed would require 32 pages.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      user cpu time       0.03 seconds
      system cpu time     0.03 seconds
      memory              1441.43k
      OS Memory           46672.00k
      Timestamp           02/06/2020 06:44:34 PM
      Step Count                        1170  Switch Count  0&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Feb 2020 00:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622909#M183268</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-07T00:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622910#M183269</link>
      <description>Apologies for misunderstanding the concept of {i}.</description>
      <pubDate>Fri, 07 Feb 2020 00:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622910#M183269</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-07T00:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622913#M183271</link>
      <description>&lt;P&gt;I believe you should try and compare SAS Date values and not strings. The string comparison as you've coded it won't return the outcome you expect and want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data &amp;amp;ds.2;
    set &amp;amp;ds.1;
    &amp;amp;out=mdy(coalesce(&amp;amp;mm,1),coalesce(&amp;amp;dd,1),&amp;amp;yy);
    if &amp;amp;out &amp;lt;= '01NOV2019'd then
      flag='yes';
    else flag='No';
    if flag='yes' then
      output;
  run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure what this Flag variable is about given that you only output rows with flag='yes'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also given that you wrote "&lt;EM&gt;I need to strip off data before 01-Nov-2019&lt;/EM&gt;" shouldn't the condition be:&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;if &amp;amp;out &amp;gt;= '01NOV2019'd then...&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 00:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622913#M183271</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-07T00:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622914#M183272</link>
      <description>&lt;P&gt;I tried the suggested code but unfortunately I got the error message in log -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Invalid argument to function MDY(2018,10,12).&lt;/P&gt;&lt;PRE&gt;MPRINT(STRIP_DT):   set auxo1;
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
SYMBOLGEN:  Macro variable YY resolves to AUDAT_YYYY
SYMBOLGEN:  Macro variable MM resolves to AUDAT_MM
SYMBOLGEN:  Macro variable DD resolves to AUDAT_DD
MPRINT(STRIP_DT):   AUDAT_=mdy(AUDAT_YYYY,coalesce(AUDAT_MM,1),coalesce(AUDAT_DD,1));
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
MPRINT(STRIP_DT):   if AUDAT_ &amp;lt;= '01NOV2019'd then flag='yes';
MPRINT(STRIP_DT):   else flag='No';
MPRINT(STRIP_DT):   if flag='yes' then output;
MPRINT(STRIP_DT):   run;

NOTE: Invalid argument to function MDY(2018,10,12) at line 22655 column 107.&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Feb 2020 00:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622914#M183272</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-07T00:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622915#M183273</link>
      <description>&lt;P&gt;Fixed the code in-between in the post. Try again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The function is MDY() so the Y variable needs to be the 3rd parameter and not the first one.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 00:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622915#M183273</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-07T00:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622916#M183274</link>
      <description>&lt;P&gt;You would likely be much better off actually using a real date if you are comparing to a single fixed date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that data step code can be pretty much reduced to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data &amp;amp;ds.2 ;
   set &amp;amp;ds.1;
   if 0&amp;lt; mdy(max(&amp;amp;mm,1),max(&amp;amp;dd,1),&amp;amp;yy) le '01NOV2019'd;

run;
&lt;/PRE&gt;
&lt;P&gt;The function MDY returns a SAS date value from numeric variables of month, day and year. Actually if the values are character but resolve to numbers then SAS will attempt to use the numeric version. The special value of a quoted string in DATE9 format ddMONyyyy with the d at the end tells SAS that this is a date literal and can compare to the date value created by the MDY function.&lt;/P&gt;
&lt;P&gt;If any of the month, day and year values are missing or result in an invalid date such as 31 November, the function MDY will return a missing value.&lt;/P&gt;
&lt;P&gt;The use of Max with the &amp;amp;mm and &amp;amp;dd variables&amp;nbsp;means that if one of the variables is missing then the month 1 or day 1 will be used to create a valid date for comparison. Which basically replicates the choices you made for the different ways of comparing with missing values.&lt;/P&gt;
&lt;P&gt;If you really need that OUT variable to indicate the date compared then use:&lt;/P&gt;
&lt;PRE&gt;data &amp;amp;ds.2 ;
   set &amp;amp;ds.1;
   &amp;amp;out =  mdy(max(&amp;amp;mm,1),max(&amp;amp;dd,1),&amp;amp;yy);
   format &amp;amp;out yymmdd10.;
   if 0&amp;lt; &amp;amp;out le '01NOV2019'd;

run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An IF without any "then" clause is a subsetting if and will only keep the observations where the If is true. Which is why I have the "if 0&amp;lt; " part. Missing values are always&amp;nbsp;less than any given value so you want to exclude those as well which would occur with a missing &amp;amp;yy variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Caution: if you have invalid date combinations like &amp;amp;mm &amp;gt; 12 or an &amp;amp;dd value not valid for a given month (and year in the case of February and leap years) then the mdy function&amp;nbsp;will return missing.&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>Fri, 07 Feb 2020 00:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622916#M183274</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-07T00:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622918#M183275</link>
      <description>&lt;P&gt;Thanks so much ! It worked absolutely fine ! But i received Missing values error which I handled by adding the below line :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My only concern is now in case of any incomplete dates - what if Day or Month is missing ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro strip_dt(yy, mm, dd, out,ds);

proc sort data=ole.&amp;amp;ds(encoding=asciiany) out=&amp;amp;ds.1; by subject;
data &amp;amp;ds.2 strip.&amp;amp;ds;
set &amp;amp;ds.1;
&lt;FONT color="#0000FF"&gt;if &amp;amp;yy ne . and &amp;amp;mm ne . and &amp;amp;dd ne . then&lt;/FONT&gt;
&amp;amp;out=mdy(coalesce(&amp;amp;mm,1),coalesce(&amp;amp;dd,1),&amp;amp;yy);
if &amp;amp;out &amp;lt;= '01NOV2019'd then
flag='yes';
else flag='No';
if flag='yes' then
output;
drop flag &amp;amp;out; 
run;

%mend strip_dt;
run;

%strip_dt(AUDAT_YYYY, AUDAT_MM, AUDAT_DD,AUDAT_,auxo);

%strip_dt(AUDAT_YYYY, AUDAT_MM, AUDAT_DD,AUDAT_,auxo5);&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Feb 2020 00:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622918#M183275</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-07T00:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622920#M183277</link>
      <description>Thanks a lot for your help! My next question was actually how to handle missing date parts. Let me try this code. Hopefully should be resolved !&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Feb 2020 00:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622920#M183277</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-07T00:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622922#M183279</link>
      <description>&lt;P&gt;I tried the suggested code but got the "Missing values were generated error" message :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;MPRINT(STRIP_DT):   data auxo52 strip.auxo5;
SYMBOLGEN:  Macro variable DS resolves to auxo5
MPRINT(STRIP_DT):   set auxo51;
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
SYMBOLGEN:  Macro variable MM resolves to AUDAT_MM
SYMBOLGEN:  Macro variable DD resolves to AUDAT_DD
SYMBOLGEN:  Macro variable YY resolves to AUDAT_YYYY
MPRINT(STRIP_DT):   AUDAT_=mdy(max(AUDAT_MM,1),max(AUDAT_DD,1),AUDAT_YYYY);
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
MPRINT(STRIP_DT):   format AUDAT_ yymmdd10.;
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
MPRINT(STRIP_DT):   if 0 &amp;lt; AUDAT_ &amp;lt;= '01NOV2019'd ;
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
MPRINT(STRIP_DT):   drop AUDAT_;
MPRINT(STRIP_DT):   run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      6 at 23186:116
NOTE: There were 3354 observations read from the data set WORK.AUXO51.
NOTE: The data set WORK.AUXO52 has 1986 observations and 44 variables.
NOTE: Compressing data set WORK.AUXO52 decreased size by 92.00 percent.
      Compressed is 4 pages; un-compressed would require 50 pages.
NOTE: The data set STRIP.AUXO5 has 1986 observations and 44 variables.
NOTE: Compressing data set STRIP.AUXO5 decreased size by 92.00 percent.
      Compressed is 4 pages; un-compressed would require 50 pages.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      user cpu time       0.04 seconds
      system cpu time     0.03 seconds
      memory              1899.62k
      OS Memory           54004.00k
      Timestamp           02/06/2020 07:53:18 PM
      Step Count                        1204  Switch Count  0&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Feb 2020 00:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622922#M183279</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-07T00:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622926#M183283</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179974"&gt;@PA8&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried the suggested code but got the "Missing values were generated error" message :&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use the macro generated code from the log and analyze your data. In below code analyse the data in table&amp;nbsp;&lt;EM&gt;missing_audat_.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Once you understand which values lead to missings you then can decide on the logic to deal with such data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data selected missing_audat_ discarded;
  set auxo51;
  AUDAT_=mdy(max(AUDAT_MM,1),max(AUDAT_DD,1),AUDAT_YYYY);
  format AUDAT_ yymmdd10.;
  if 0 &amp;lt; AUDAT_ &amp;lt;= '01NOV2019'd then output selected;
  else if missing(AUDAT_) then output missing_audat_;
  else output discarded;
  drop AUDAT_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As a general remark: It's often better to first develop and test working SAS code and only if this does what you need generalize the code and add the macro bits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 02:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622926#M183283</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-07T02:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622928#M183284</link>
      <description>You are absolutely right ! Thanks a lot for your guidance and support.</description>
      <pubDate>Fri, 07 Feb 2020 02:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/622928#M183284</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-07T02:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/623101#M183366</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179974"&gt;@PA8&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried the suggested code but got the "Missing values were generated error" message :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;MPRINT(STRIP_DT):   data auxo52 strip.auxo5;
SYMBOLGEN:  Macro variable DS resolves to auxo5
MPRINT(STRIP_DT):   set auxo51;
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
SYMBOLGEN:  Macro variable MM resolves to AUDAT_MM
SYMBOLGEN:  Macro variable DD resolves to AUDAT_DD
SYMBOLGEN:  Macro variable YY resolves to AUDAT_YYYY
MPRINT(STRIP_DT):   AUDAT_=mdy(max(AUDAT_MM,1),max(AUDAT_DD,1),AUDAT_YYYY);
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
MPRINT(STRIP_DT):   format AUDAT_ yymmdd10.;
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
MPRINT(STRIP_DT):   if 0 &amp;lt; AUDAT_ &amp;lt;= '01NOV2019'd ;
SYMBOLGEN:  Macro variable OUT resolves to AUDAT_
MPRINT(STRIP_DT):   drop AUDAT_;
MPRINT(STRIP_DT):   run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      6 at 23186:116
NOTE: There were 3354 observations read from the data set WORK.AUXO51.
NOTE: The data set WORK.AUXO52 has 1986 observations and 44 variables.
NOTE: Compressing data set WORK.AUXO52 decreased size by 92.00 percent.
      Compressed is 4 pages; un-compressed would require 50 pages.
NOTE: The data set STRIP.AUXO5 has 1986 observations and 44 variables.
NOTE: Compressing data set STRIP.AUXO5 decreased size by 92.00 percent.
      Compressed is 4 pages; un-compressed would require 50 pages.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      user cpu time       0.04 seconds
      system cpu time     0.03 seconds
      memory              1899.62k
      OS Memory           54004.00k
      Timestamp           02/06/2020 07:53:18 PM
      Step Count                        1204  Switch Count  0&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;6 out of 3354 input records =&amp;gt; data values likely the issue.&lt;/P&gt;
&lt;P&gt;I would add something like&lt;/P&gt;
&lt;PRE&gt;         if missing(Audat_) then put "ERROR: Record=" _n_ +1 &amp;amp;mm= +1 &amp;amp;dd= +1 &amp;amp;yy=;
&lt;/PRE&gt;
&lt;P&gt;to the code to get diagnostics which will tell you which observation of the source data set has the data value problem(s).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 16:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/623101#M183366</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-07T16:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to resolve a nested macro variable inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/623559#M183603</link>
      <description>Thank you very much for all your help ! Really appreciate !</description>
      <pubDate>Mon, 10 Feb 2020 14:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-resolve-a-nested-macro-variable-inside-a-macro/m-p/623559#M183603</guid>
      <dc:creator>PA8</dc:creator>
      <dc:date>2020-02-10T14:15:28Z</dc:date>
    </item>
  </channel>
</rss>

