<?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: How to condition with Macro calculation? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446018#M111840</link>
    <description>&lt;P&gt;What is the value of &amp;amp;missp? What type of variable is A, numeric or character? And what do some of the values look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Mar 2018 22:32:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-03-15T22:32:04Z</dc:date>
    <item>
      <title>How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446006#M111837</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried a code with "if a&amp;gt;&amp;amp;missp then b=.; " it works.&lt;/P&gt;&lt;P&gt;But when I tried&amp;nbsp;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&amp;amp;missp/100 then &lt;/SPAN&gt;&lt;SPAN&gt;b&lt;/SPAN&gt;&lt;SPAN&gt;=.; " It did not work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Why? What is the right way to condition with Macro calculation?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 21:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446006#M111837</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-15T21:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446009#M111839</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194581"&gt;@xiangpang&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried a code with "if a&amp;gt;&amp;amp;missp then b=.; " it works.&lt;/P&gt;
&lt;P&gt;But when I tried&amp;nbsp;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&amp;amp;missp/100 then &lt;/SPAN&gt;&lt;SPAN&gt;b&lt;/SPAN&gt;&lt;SPAN&gt;=.; " It did not work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Why? What is the right way to condition with Macro calculation?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Neither of those statements are macro code so they should work just fine in your data step.&lt;/P&gt;
&lt;P&gt;Now if the macro variable MISSP does not contain either a numeric literal value (like 45) or the name of a numeric variable (like C) then you might generate a syntax error.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 21:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446009#M111839</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-15T21:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446018#M111840</link>
      <description>&lt;P&gt;What is the value of &amp;amp;missp? What type of variable is A, numeric or character? And what do some of the values look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 22:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446018#M111840</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-15T22:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446030#M111844</link>
      <description>&lt;P&gt;Sorry for the confuse.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code like this. all the data is number. But I want to use 10 as missp, so I want create something like &amp;amp;missp/100 instead &amp;amp;missp.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input ID y d z w;
cards;
1 1 38 38 23
2 1 30 45 19
4 1 56 45 23
4 0 67 13 67  
4 1 48 35 56 
;
run;

%Macro miss(missp);
data b;
set a;
c=ranuni(0); 
if c&amp;gt;&amp;amp;missp then d=.; 
run;
%mend;
%miss(0.9);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 00:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446030#M111844</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-16T00:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446075#M111864</link>
      <description>&lt;P&gt;I think you are saying you want the user to pass in an integer and have that integer be divided by 100?&lt;/P&gt;
&lt;P&gt;There is no reason that would not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you are using the value in a data step statement just add the '/100' into the constant part of statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if c&amp;gt;(&amp;amp;missp/100) then d=.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So if you make that change and call the macro like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%miss(90)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then the macro will generate this statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if c&amp;gt;(90/100) then d=.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which does the same thing as the line that the old macro would have generated it you passed in 0.9.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if c&amp;gt;0.9 then d=.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 04:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446075#M111864</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-16T04:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446082#M111868</link>
      <description>&lt;P&gt;"It did not work" is one of the most &lt;STRONG&gt;UNHELPFUL&lt;/STRONG&gt; statements a person can make. It tells us &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;exactly nothing&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; about the problem, and is worthy of the proverbial blonde secretary (no offense to people with fair hair here).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show code, show log, show example data (see &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;data2datastep&lt;/A&gt; and &lt;A href=" and how to post code" target="_blank"&gt;how to post code&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 06:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446082#M111868</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-16T06:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446120#M111883</link>
      <description>&lt;P&gt;Thanks Tom, I found "%sysevalf" working for my code, but not&amp;nbsp;%eval. I think eval for integer while sysevalf not.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 12:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446120#M111883</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-16T12:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446167#M111893</link>
      <description>&lt;P&gt;You must use %sysevalf() if you want to do non integer arithmetic in macro code.&amp;nbsp; This include comparisons. %EVAL() is what %if , %while and %until use by default.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You compare two strings that look like integers with %EVAL() and it will do a numeric comparison. But if either includes a decimal point then it compare them as strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also need to use %sysevalf() if you want to use date literals like '01JAN2017'd in your comparisons or calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you ask a question make sure to include important details.&amp;nbsp; The example code you posted in your original question and in your follow-up response never showed any place where SAS would have used %eval().&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 14:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446167#M111893</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-16T14:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446193#M111908</link>
      <description>&lt;P&gt;Hello, Tom, thanks for your explanation and suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;(&amp;amp;missp/100) then &lt;/SPAN&gt;&lt;SPAN&gt;b&lt;/SPAN&gt;&lt;SPAN&gt;=.; " It did not work last night. There is no error in log, but the number produced is not right. So I tried to find other ways to solve the problem. That is why I used %eval and %sysevalf later.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The weird thing is I just run "if a&amp;gt;(&amp;amp;missp/100) then b=.; " again. It works, It happened before when I close SAS program and restart computer. I don't know why.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Again I appreciate your help and the suggestion from other people.&amp;nbsp;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 14:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446193#M111908</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-16T14:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446676#M112115</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194581"&gt;@xiangpang&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello, Tom, thanks for your explanation and suggestion.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;(&amp;amp;missp/100) then &lt;/SPAN&gt;&lt;SPAN&gt;b&lt;/SPAN&gt;&lt;SPAN&gt;=.; " It did not work last night. There is no error in log, but the number produced is not right. So I tried to find other ways to solve the problem. That is why I used %eval and %sysevalf later.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The weird thing is I just run "if a&amp;gt;(&amp;amp;missp/100) then b=.; " again. It works, It happened before when I close SAS program and restart computer. I don't know why.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Again I appreciate your help and the suggestion from other people.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Anytime this happens, inspect all your programs that ran in this session for an options statement that sets obs=. See Maxim 9.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 07:11:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446676#M112115</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-19T07:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to condition with Macro calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446743#M112139</link>
      <description>&lt;P&gt;Thanks for the suggestion.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 12:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-condition-with-Macro-calculation/m-p/446743#M112139</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-03-19T12:18:08Z</dc:date>
    </item>
  </channel>
</rss>

