<?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: %IF %Then%do macro doesn't work? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365421#M64754</link>
    <description>&lt;P&gt;The error is clear. You have three %do without any matching %end for them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, your logic doesn't make sense. There no reason to make this into a macro that can be seen.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2017 15:42:12 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-06-08T15:42:12Z</dc:date>
    <item>
      <title>%IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365417#M64753</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a regular SAS program, and I would like to creat a macro base on its condition.&amp;nbsp; However the Log shows an error massage, please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;data &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;dataout;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;datain;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/BDS/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_cdate/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; found=2&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_de_notes/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; found=3&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_den_pcr_perf/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; found=4&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;prescreen&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;data &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;dataout;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;datain;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/BDS/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_cdate/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; found=2&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_de_notes/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; found=3&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_den_pcr_perf/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; found=4&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: There were 3 unclosed %DO statements. The macro PRESCREEN will not be compiled.&lt;/P&gt;&lt;P&gt;ERROR: A dummy macro will be compiled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 15:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365417#M64753</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-08T15:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365421#M64754</link>
      <description>&lt;P&gt;The error is clear. You have three %do without any matching %end for them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, your logic doesn't make sense. There no reason to make this into a macro that can be seen.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 15:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365421#M64754</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-08T15:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365422#M64755</link>
      <description>&lt;P&gt;Each %DO needs its %END.&lt;/P&gt;
&lt;P&gt;You have more %DO then %END - thats the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Besides, entering a data atep in macro doesn't need change IF into %IF.&lt;/P&gt;
&lt;P&gt;And I dont see any reason to put the data step into %maco program, unless you&lt;/P&gt;
&lt;P&gt;supply arguments by macro variables.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 15:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365422#M64755</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-06-08T15:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365423#M64756</link>
      <description>&lt;P&gt;Very simple. Every %do needs a corresponding %end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you need to be aware that your macro won`t work, as the variable that is pointed to by &amp;amp;var is not present when the macro executes.&lt;/P&gt;
&lt;P&gt;Since the only thing that is dynamic in your code is the variable name provided through &amp;amp;var, you don't need the macro at all.&lt;/P&gt;
&lt;P&gt;Or you should keep the code as it is, and just provide var as a macro parameter:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro prescreen(datain,dataout,var);
data &amp;amp;dataout;
set &amp;amp;datain;
if prxmatch("m/BDS/i",&amp;amp;var) &amp;gt; 0 then found=1;
else if prxmatch("m/lab_cdate/i",&amp;amp;var) &amp;gt; 0 then found=2;
else if prxmatch("m/lab_de_notes/i",&amp;amp;var) &amp;gt; 0 then found=3;
else if prxmatch("m/lab_den_pcr_perf/i",&amp;amp;var) &amp;gt; 0 then found=4;
else found=0;
run;
%mend;

%prescreen(have,want,some_variable_name);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Jun 2017 15:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365423#M64756</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-08T15:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365427#M64758</link>
      <description>&lt;P&gt;You are making a common mistake of mixing Dataset code with Macro code. &amp;nbsp;%if constructs are part of the macro language, not datastep. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro prescreen;
data dataout;
set datain;
if prxmatch("m/BDS/i",&amp;amp;var) &amp;gt; 0 then found=1;
if prxmatch("m/lab_cdate/i",&amp;amp;var) &amp;gt; 0 then found=2;
if prxmatch("m/lab_de_notes/i",&amp;amp;var) &amp;gt; 0 then found=3;
if prxmatch("m/lab_den_pcr_perf/i",&amp;amp;var) &amp;gt; 0 then found=4;
else found=0;
%end;
%mend;
 &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However I totally agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;as I don't see any value in macro-tizing this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 15:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365427#M64758</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-08T15:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365433#M64760</link>
      <description>&lt;P&gt;Thanks for your great suggestion.&amp;nbsp; I have another problem.&amp;nbsp; I created some macros first.&amp;nbsp; How to change the&amp;nbsp;() name&amp;nbsp;after&amp;nbsp;'Precscreen'&amp;nbsp;below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Var=Newvar;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DataIN=pose;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DataOUT=UNmatch;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prescreen(datain,dataout,var);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;data MS&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;amp;dataout;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set MS&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;amp;datain;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/BDS/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; then found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;else if prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_cdate/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; then found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;else if prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_de_notes/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; then found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;else if prxmatch(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"m/lab_den_pcr_perf/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; then found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;else found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;prescreen&lt;/I&gt;&lt;/STRONG&gt;(POSE,UNmatch,Newvar);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 16:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365433#M64760</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-08T16:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365439#M64761</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your great suggestion.&amp;nbsp; I have another problem.&amp;nbsp; I created some macros first.&amp;nbsp; How to change the&amp;nbsp;() name&amp;nbsp;after&amp;nbsp;'Precscreen'&amp;nbsp;below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Change what???&lt;/P&gt;
&lt;P&gt;The () are required to show they are the macro parameters. Since you have 3 parameters "named" is that what you are looking for how to change NewVar to a different variable name??&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 16:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365439#M64761</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-08T16:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365451#M64762</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your great suggestion.&amp;nbsp; I have another problem.&amp;nbsp; I created some macros first.&amp;nbsp; How to change the&amp;nbsp;() name&amp;nbsp;after&amp;nbsp;'Precscreen'&amp;nbsp;below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Var=Newvar;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DataIN=pose;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DataOUT=UNmatch;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; prescreen(datain,dataout,var);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;data MS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;amp;dataout;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set MS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;amp;datain;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if prxmatch(&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"m/BDS/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; then found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;else if prxmatch(&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"m/lab_cdate/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; then found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;else if prxmatch(&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"m/lab_de_notes/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; then found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;else if prxmatch(&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"m/lab_den_pcr_perf/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;var) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; then found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;else found=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;prescreen&lt;/I&gt;&lt;/STRONG&gt;(POSE,UNmatch,Newvar);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The three macro parameters from the macro &lt;U&gt;definition&lt;/U&gt;&lt;U&gt;&lt;/U&gt;&lt;U&gt;&lt;/U&gt;&lt;U&gt;&lt;/U&gt;&amp;nbsp;are assigned the three texts you wrote in the macro &lt;U&gt;call&lt;/U&gt;. Therefore the three %let's before the macro definition are not needed and in fact useless.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 17:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365451#M64762</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-08T17:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365454#M64763</link>
      <description>&lt;P&gt;If you want to use the values of your macro varibles in the call to your macro then just expand them the same way your would reference the values of those macro variables anywhere else.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Var=Newvar;
%let DataIN=pose;
%let DataOUT=UNmatch;
 
%prescreen(&amp;amp;DataIn,&amp;amp;DataOUT,&amp;amp;Var);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also&amp;nbsp;one of the nice things about SAS macros is that you can&amp;nbsp;assign the values by name in the call , even when the parameters are defined as positional in the macro definition. &amp;nbsp;This makes the program with the macro call easier to read since you can see the parameter name and not just its position. In fact with named parameter values in the call you can order the parmeters how ever you want in the call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%prescreen(var=Newvar,datain=pose,dataout=UNmatch)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 17:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365454#M64763</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-08T17:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: %IF %Then%do macro doesn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365691#M64774</link>
      <description>&lt;P&gt;Thanks for all your great help.&amp;nbsp; I got it work. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 14:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-Then-do-macro-doesn-t-work/m-p/365691#M64774</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-09T14:26:45Z</dc:date>
    </item>
  </channel>
</rss>

