<?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 condition with macro variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686410#M208279</link>
    <description>As my example i have only one character to check.  LIKE 1 2 3 4 5 A B C D These flags which i need to check , provided is just an example. But going through always false and Flag is being assign as N</description>
    <pubDate>Thu, 24 Sep 2020 15:43:26 GMT</pubDate>
    <dc:creator>Aman4SAS</dc:creator>
    <dc:date>2020-09-24T15:43:26Z</dc:date>
    <item>
      <title>If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686401#M208273</link>
      <description>Hi All, I need to compare 2 macro variables but i am getting always condition false while condition is true as per my data. Please help&lt;BR /&gt;Code:&lt;BR /&gt;DATA X;&lt;BR /&gt;INPUT X$ Y$;&lt;BR /&gt;DATALINES;&lt;BR /&gt;X 2&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;BR /&gt;DATA Y;&lt;BR /&gt;X="2";&lt;BR /&gt;RUN;&lt;BR /&gt;%MACRO TEST();&lt;BR /&gt;%GLOBAL FLAG;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;SELECT DISTINCT X,Y INTO :A,:B FROM X;&lt;BR /&gt;QUIT;&lt;BR /&gt;%LET A=%LEFT(%TRIM(&amp;amp;A));&lt;BR /&gt;%LET B=%LEFT(%TRIM(&amp;amp;B));&lt;BR /&gt;%IF &amp;amp;A. = %BQUOTE('&amp;amp;B.') %THEN &lt;BR /&gt;%LET FLAG=Y;&lt;BR /&gt;%ELSE &lt;BR /&gt;%LET FLAG=N;&lt;BR /&gt;%MEND;&lt;BR /&gt;DATA NEW;&lt;BR /&gt;SET Y;&lt;BR /&gt;CALL EXECUTE('%TEST();');&lt;BR /&gt;FLAG=SYMGET('FLAG');&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;Please help</description>
      <pubDate>Thu, 24 Sep 2020 15:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686401#M208273</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2020-09-24T15:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686406#M208275</link>
      <description>&lt;P&gt;This is not working because the call execute executes after the data step is complete, so FLAG isn't set until after the data step is done.&lt;/P&gt;
&lt;P&gt;Why are you calling the macro using call execute?&amp;nbsp; Is this just an example from a larger solution?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 15:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686406#M208275</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T15:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686407#M208276</link>
      <description>&lt;P&gt;Show some example values from both of these "variables" and why you think they are equal.&lt;/P&gt;
&lt;P&gt;Or set&lt;/P&gt;
&lt;P&gt;Options mprint mlogic symbolgen before running your macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %Left (%Trim( &amp;amp;A.)) is not going to remove, reduce or effect the spacing between different bits of &amp;amp;A. The whole string gets shifted left and the only thing "trimmed" is what comes after the last bit.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;%let A =   Some      words   with differing spaces     betweeeen    ;
%let A = %trim(%left(&amp;amp;A.));

%put &amp;amp;A.;
&lt;/PRE&gt;
&lt;P&gt;You might need to Strip the variables (equivalent to Left(trim())) and specify Separated by ' ' to force on blank between&amp;nbsp; the values of the variables. However if some values of the A or B data set variables have differing numbers of blanks embedded in them you really need to provide example data and what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 15:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686407#M208276</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-24T15:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686408#M208277</link>
      <description>Its just an example, i need to use it with big data by checking multiple conditions and need to call macro recursivly untill i reach my end node&lt;BR /&gt;Is there any solution?</description>
      <pubDate>Thu, 24 Sep 2020 15:40:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686408#M208277</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2020-09-24T15:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686409#M208278</link>
      <description>&lt;P&gt;Well this version works.&amp;nbsp; How does it not work in your situation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA X;
INPUT X$ Y$;
DATALINES;
X 2
;
RUN;
DATA Y;
X="2";
RUN;
%MACRO TEST();
  %GLOBAL FLAG;
  PROC SQL;
  SELECT DISTINCT X,Y INTO :A,:B FROM X;
  QUIT;
  %LET A=%LEFT(%TRIM(&amp;amp;A));
  %LET B=%LEFT(%TRIM(&amp;amp;B));
  %IF &amp;amp;A. = %BQUOTE('&amp;amp;B.') %THEN
  %LET FLAG=Y;
  %ELSE
  %LET FLAG=N;
%MEND;
%TEST();
DATA NEW;
SET Y;
FLAG="&amp;amp;FLAG";
RUN;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2020 15:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686409#M208278</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T15:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686410#M208279</link>
      <description>As my example i have only one character to check.  LIKE 1 2 3 4 5 A B C D These flags which i need to check , provided is just an example. But going through always false and Flag is being assign as N</description>
      <pubDate>Thu, 24 Sep 2020 15:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686410#M208279</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2020-09-24T15:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686411#M208280</link>
      <description>&lt;P&gt;Your example is confusing me.&amp;nbsp; You are trying to call that macro while accessing data set Y, but you are not actually referencing any values in that table.&lt;/P&gt;
&lt;P&gt;I suggest backing up and telling us what you are trying to do, as I don't think this approach will work.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 15:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686411#M208280</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T15:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686412#M208281</link>
      <description>Not able to understand, u call macro outside of datastep it will run only 1 time, and u r getting Flag value Y?</description>
      <pubDate>Thu, 24 Sep 2020 15:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686412#M208281</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2020-09-24T15:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686413#M208282</link>
      <description>&lt;P&gt;The value is always false because you are always comparing "X" to "2" from dataset X.&amp;nbsp; You aren't accessing anything from dataset Y.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 15:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686413#M208282</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T15:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686414#M208283</link>
      <description>&lt;P&gt;I suspect you could solve this with a custom made format.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 15:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686414#M208283</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T15:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686415#M208284</link>
      <description>Apology, &lt;BR /&gt;I have a table with conditions&lt;BR /&gt;I have created macrovariables for conditions where macro variable A is column name and Macro variable b is value. While calling inside datastep condition need to check with row. And want to all flag. Its only step. If condition get true i will pick another variable as reference to pick another condition as macro variable and will check again untill last node. &lt;BR /&gt;&lt;BR /&gt;My problem is here when macro variable are resolving correct value as per data why my condition is not getting true&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Sep 2020 15:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686415#M208284</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2020-09-24T15:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686417#M208286</link>
      <description>Same is working , diff is not proc sql to create macro varible;&lt;BR /&gt;Code:&lt;BR /&gt;%GLOBAL FLAG;&lt;BR /&gt;%MACRO TEST();&lt;BR /&gt;%LET VAR=NAME;&lt;BR /&gt;%LET SEX=M;&lt;BR /&gt;%LET COND= =;&lt;BR /&gt;%IF &amp;amp;VAR &amp;amp;COND %BQUOTE('&amp;amp;SEX') %THEN %LET FLAG=Y;&lt;BR /&gt;%ELSE %LET FLAG=N;&lt;BR /&gt;%MEND;&lt;BR /&gt;DATA NEW;&lt;BR /&gt;SET SASHELP.CLASS;&lt;BR /&gt;CALL EXECUTE('TEST();');&lt;BR /&gt;FLAG=CALL SYMGET('FLAG');&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;Its working fine.&lt;BR /&gt;&lt;BR /&gt;Plz help</description>
      <pubDate>Thu, 24 Sep 2020 16:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686417#M208286</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2020-09-24T16:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686419#M208288</link>
      <description>&lt;P&gt;You can't refer to DATA set variables like NAME using a macro variable &amp;amp;VAR inside a macro. When you use &amp;amp;VAR to refer to a data set variable, you must use it inside a SAS data step. If you want to compare a data set variable to some other value, it must be done in a DATA step, using a data step IF statement and not a macro %IF statement, which only compares macro variables to a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So nothing you are trying to do with this macro will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could, however, create code like this, that works inside a DATA step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET VAR=NAME;
%LET SEX=M;
%LET COND= =;

data want;
    set sashelp.class;
    if &amp;amp;var &amp;amp;cond "&amp;amp;sex" then flag='Y';
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, your logic still fails, but the code produces no errors. Why does the code work now? Because &amp;amp;VAR is replaced with NAME and &amp;amp;COND is replaced by = and &amp;amp;SEX is replaced by M, yielding the line of code &lt;FONT face="courier new,courier"&gt;if name="M" then flag='Y';&lt;/FONT&gt;&amp;nbsp;inside a DATA step, which is indeed valid SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The logic fails because there are no observations in SASHELP.CLASS for which the variable NAME is equal to the value of "M". But I leave that up to you to fix.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 16:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686419#M208288</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-24T16:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686423#M208292</link>
      <description>&lt;P&gt;Remember, macro write code, they cannot read the values in a data step.&lt;/P&gt;
&lt;P&gt;I think this is what you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA X;
INPUT X$ Y$;
DATALINES;
X 2
;
RUN;
DATA Y;
X="2"; 
RUN;
%MACRO TEST();
  %let dsid = %sysfunc(open(work.X));
  %do %while(%sysfunc(fetch(&amp;amp;dsid)) = 0);
    %let varname = %sysfunc(getvarc(&amp;amp;dsid,1));
    %let varval = %sysfunc(getvarc(&amp;amp;dsid,2)); 
    if &amp;amp;varname = "&amp;amp;varval" then FLAG = 'Y';
    else FLAG = 'N'; 
  %end;
  %let rc   = %sysfunc(close(&amp;amp;dsid));
%MEND;
options mprint;
DATA NEW;
SET Y;
%TEST();
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice the MPRINT option.&amp;nbsp; This will show you in the log the code that got created.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 16:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686423#M208292</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T16:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686426#M208294</link>
      <description>&lt;P&gt;Here is a call execute version.&amp;nbsp; Remember all it does is write code as well.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set x end=finished;
  if _n_ = 1 then do;
    CALL EXECUTE('DATA NEW;');
    CALL EXECUTE('SET Y;');
  end;
  CALL EXECUTE('if ' || X || ' = "' || strip(Y) || '" then FLAG="Y";');
  CALL EXECUTE('else FLAG="N";');
  if finished then do;
    CALL EXECUTE('run;');
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2020 16:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686426#M208294</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T16:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686433#M208299</link>
      <description>&lt;P&gt;Adding to my reply above&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a macro that does what you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro subset(dsn=,var=,cond=,value=);
data want;
    set &amp;amp;dsn;
    if &amp;amp;var &amp;amp;cond "&amp;amp;value" then flag='Y';
run;
%mend;

/* Example: */
%subset(dsn=sashelp.class,var=name,cond=%str(=),value=Jane)

/* Example 2: */
%subset(dsn=sashelp.class,var=name,cond=%str(=:),value=J)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Works when &amp;amp;var references a data set character variable. Note that the comparison of the data step variable is done in a data step IF statement and not in a macro %IF statement, which cannot compare data step variables to a value.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 17:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686433#M208299</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-24T17:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686456#M208312</link>
      <description>Thanks a lot, it works, but i need to create this x table again n again like i have 10 conditions on diff diff variables i need to check every variable with conditions for each row. By this i wont be able to create x dynamicly. I need to pick 1st row for 1st condition , 2nd row for 2nd condition, i need to call same macro recursively. Thanks again</description>
      <pubDate>Thu, 24 Sep 2020 18:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686456#M208312</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2020-09-24T18:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686459#M208314</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39317"&gt;@Aman4SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;By this i wont be able to create x dynamicly. I need to pick 1st row for 1st condition , 2nd row for 2nd condition, i need to call same macro recursively.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show us what you mean, "pick 1st row..."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should be able to call the macro from within a data set using the code from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339357"&gt;@CurtisMackWSIPP&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 18:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686459#M208314</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-24T18:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686460#M208315</link>
      <description>&lt;P&gt;You can just add rows to the X table and it should work.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 18:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686460#M208315</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T18:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: If condition with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686465#M208318</link>
      <description>&lt;P&gt;You can't call a macro for every row in a data step.&amp;nbsp; The macros write code that is then executed.&amp;nbsp; Look at this call execute that will sets FLAG to equal which variable matched the values in the X.&amp;nbsp; Pay attention to the log.&amp;nbsp; It will show you the code that is actually generated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA X;
INPUT X$ Y$;
DATALINES;
X 2
Y 4 
;
RUN;
DATA Y;
X="2";Y="0"; output;
X="0";Y="4"; output;
X="5";Y="3"; output;
RUN;
data _null_;
  set x end=finished;
  if _n_ = 1 then do;
    CALL EXECUTE('DATA NEW;');
    CALL EXECUTE('SET Y;');
    CALL EXECUTE('if 0 = 1 then FLAG="";');
  end;
  CALL EXECUTE('else if ' || X || ' = "' || strip(Y) || '" then FLAG="' || strip(X) || '";');
  if finished then do;
    CALL EXECUTE('else FLAG="N";');
    CALL EXECUTE('run;');
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2020 18:28:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-condition-with-macro-variables/m-p/686465#M208318</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-24T18:28:47Z</dc:date>
    </item>
  </channel>
</rss>

