<?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: problem with sas code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387347#M92877</link>
    <description>&lt;P&gt;I repeat again:&lt;/P&gt;
&lt;P&gt;2 things, as mentioned before:&lt;/P&gt;
&lt;P&gt;- Post test data in the form of a datastep in the post using the {i} code window.&lt;/P&gt;
&lt;P&gt;- Macro is not needed. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you insiting on not using Base SAS?&lt;/P&gt;
&lt;PRE&gt;%let value=150;

data conditional;
  set matchmerge_mtcars;
  hp=ifn(price&amp;gt;&amp;amp;value.,price*0.3,price);
run;&lt;/PRE&gt;
&lt;P&gt;As for your question specifically, its because you don't understand what its doing. &amp;nbsp;Macro&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;is not&lt;/STRONG&gt;&lt;/U&gt; Base SAS, it is a find and replace system to generate text. &amp;nbsp;You %if statement generates a datastep statement, but is not within a datastep. &amp;nbsp;Really suggest learning Base SAS, then move onto Macro later on as it really doesn't add anything until you know what it is for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Aug 2017 14:27:51 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-08-11T14:27:51Z</dc:date>
    <item>
      <title>problem with sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387342#M92874</link>
      <description>&lt;P&gt;I am submitting the below code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let value = 150;&lt;BR /&gt;%macro if_then_else(dataset,var1,var);&lt;BR /&gt;data conditional;&lt;BR /&gt;set &amp;amp;dataset;run;&lt;BR /&gt;%if &amp;amp;var1 &amp;gt; &amp;amp;value %then &amp;amp;var=&amp;amp;var*0.3 + &amp;amp;var;&lt;BR /&gt;%else &amp;amp;var = &amp;amp;var;&lt;BR /&gt;proc print data=conditional;run;&lt;BR /&gt;%mend if_then_else;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if_then_else(matchmerge_mtcars,hp,price);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am ending up with the error:&amp;nbsp;&lt;SPAN&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 14:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387342#M92874</guid>
      <dc:creator>atulsingh</dc:creator>
      <dc:date>2017-08-11T14:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: problem with sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387343#M92875</link>
      <description>&lt;P&gt;Show us a representative portion of your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the SASLOG (with option MPRINT turned on).&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 14:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387343#M92875</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-08-11T14:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: problem with sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387346#M92876</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1111.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14444iDEC7BABE9446A6E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1111.png" alt="1111.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 14:26:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387346#M92876</guid>
      <dc:creator>atulsingh</dc:creator>
      <dc:date>2017-08-11T14:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: problem with sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387347#M92877</link>
      <description>&lt;P&gt;I repeat again:&lt;/P&gt;
&lt;P&gt;2 things, as mentioned before:&lt;/P&gt;
&lt;P&gt;- Post test data in the form of a datastep in the post using the {i} code window.&lt;/P&gt;
&lt;P&gt;- Macro is not needed. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you insiting on not using Base SAS?&lt;/P&gt;
&lt;PRE&gt;%let value=150;

data conditional;
  set matchmerge_mtcars;
  hp=ifn(price&amp;gt;&amp;amp;value.,price*0.3,price);
run;&lt;/PRE&gt;
&lt;P&gt;As for your question specifically, its because you don't understand what its doing. &amp;nbsp;Macro&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;is not&lt;/STRONG&gt;&lt;/U&gt; Base SAS, it is a find and replace system to generate text. &amp;nbsp;You %if statement generates a datastep statement, but is not within a datastep. &amp;nbsp;Really suggest learning Base SAS, then move onto Macro later on as it really doesn't add anything until you know what it is for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 14:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387347#M92877</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-11T14:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: problem with sas code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387356#M92879</link>
      <description>&lt;P&gt;Here is the code that your macro generates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data conditional;&lt;BR /&gt;set matchmerge_mtcars;run;&lt;/P&gt;
&lt;P&gt;price=price&lt;/P&gt;
&lt;P&gt;proc print data=conditional;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you see anything wrong with it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The real issue is understanding what macro language does, and why this is the resulting program. &amp;nbsp;Notice:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%IF %THEN statements come after the RUN statement. &amp;nbsp;Whatever they do (and they are not doing the right thing), the result is not part of the DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you were to move the RUN statement, there is no reason to use %IF %THEN in this program. &amp;nbsp;%IF %THEN generates statements that can become part of the DATA step, but %IF %THEN never never never processes each observation in the data set. &amp;nbsp;IF THEN would be an acceptable tool (also see the&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;suggestion).&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 14:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-sas-code/m-p/387356#M92879</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-11T14:42:18Z</dc:date>
    </item>
  </channel>
</rss>

