<?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 clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227264#M40927</link>
    <description>&lt;P&gt;I'm not getting the value of _n_ after I place the end statement. I should have get the value of _n_ for the first do lopp atleast, but not.&lt;/P&gt;</description>
    <pubDate>Fri, 25 Sep 2015 13:23:52 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2015-09-25T13:23:52Z</dc:date>
    <item>
      <title>If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227233#M40910</link>
      <description>&lt;P&gt;When I run the following code, I got 'not success' in the log where as I'm execpting 'sucess' message in the log. Can someone explain this code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end_title=1565;
%macro test;
data test1;
if %eval(&amp;amp;end_title)&amp;lt;1565&amp;lt; %eval(&amp;amp;end_title)+%eval(&amp;amp;end_title) then put 'success';
else put "notsucess";
_n=%eval(&amp;amp;end_title)+%eval(&amp;amp;end_title);
run;
%mend test;
%test&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Sep 2015 10:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227233#M40910</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-09-25T10:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227236#M40912</link>
      <description>&lt;P&gt;That's a question that pops up from time to time .,.. here's oen thread you can look at:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Macro-resolving/m-p/218619#M40282" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Macro-resolving/m-p/218619#M40282&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 11:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227236#M40912</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-09-25T11:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227238#M40914</link>
      <description>&lt;P&gt;Could you please tell me how to print the value of _n_ &amp;nbsp;in log from the following code? I could not see the value of _n_ after placing the put _all_ statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 1&amp;lt;_n_&amp;lt; %eval(&amp;amp;end_title) then do; put option;end;
put _all_;
if _n_=%eval(&amp;amp;end_title) then do; put option;		
put _all_;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 11:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227238#M40914</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-09-25T11:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227253#M40918</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets start again. &amp;nbsp;What are you attempting to do. &amp;nbsp;There is nothing there (again) which needs macro code. &amp;nbsp;There is then the difference in the code you posted, in the first instance you use _n which is a variable or macro variable? &amp;nbsp;in the latest post you use _n_ wihch is an automatic variable for row number. &amp;nbsp;What is the purpose, the logic, i.e. what goes in (as a datastep) and what do you want the output to look like.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 12:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227253#M40918</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-25T12:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227255#M40920</link>
      <description>&lt;P&gt;My first and second post is not related to each other. I missed to start a new thread for my second post. I need to get the value the _n_ in SAS log. When I tried this code, I'm not getting the value of _n_ in SAS log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 1&amp;lt;_n_&amp;lt; %eval(&amp;amp;end_title) then do; put option;end;
put _all_;
if _n_=%eval(&amp;amp;end_title) then do; put option;		
put _all_;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried this code as well, but could not suceeed.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 1&amp;lt;_n_&amp;lt; %eval(&amp;amp;end_title) then do; put option;end;
put _n_=;
if _n_=%eval(&amp;amp;end_title) then do; put option;		
put _n_=;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Sep 2015 12:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227255#M40920</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-09-25T12:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227257#M40922</link>
      <description>&lt;P&gt;put _all_ will include writing _n_. &amp;nbsp;If you want _n_ only, you could try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;put _n_=;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 13:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227257#M40922</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-09-25T13:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227259#M40923</link>
      <description>I did tried as I said my previous, but I could not see the value of _n_ in SAS log.</description>
      <pubDate>Fri, 25 Sep 2015 13:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227259#M40923</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-09-25T13:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227261#M40924</link>
      <description>&lt;P&gt;You seem to be missing a END for your second DO.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 13:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227261#M40924</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-09-25T13:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227262#M40925</link>
      <description>&lt;P&gt;Sorry, you still have not explained what you are trying to do, what is the input data, what is the output requirement. &amp;nbsp;The reason is in base SAS, this works fine:&lt;/P&gt;&lt;P&gt;data tmp;&lt;BR /&gt;set sashelp.cars;&lt;BR /&gt;put _n_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It prints the row number for each record in the dataset. &amp;nbsp;I can't see what your trying to do.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 13:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227262#M40925</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-25T13:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227263#M40926</link>
      <description>&lt;P&gt;Looks like it is working to me.&lt;/P&gt;&lt;P&gt;1565 is NOT less than 1565. &amp;nbsp;So the ELSE clause should execute.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 13:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227263#M40926</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-09-25T13:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227264#M40927</link>
      <description>&lt;P&gt;I'm not getting the value of _n_ after I place the end statement. I should have get the value of _n_ for the first do lopp atleast, but not.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 13:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227264#M40927</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-09-25T13:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227265#M40928</link>
      <description>After macro replacement your if clause is&lt;BR /&gt;&lt;BR /&gt;if 1565&amp;lt;1565&amp;lt;1565+1565 then put 'success';&lt;BR /&gt;else put "notsucess";&lt;BR /&gt;&lt;BR /&gt;1565 is not les than 1565 so the else clause is executed and print "notsucess" message</description>
      <pubDate>Fri, 25 Sep 2015 13:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227265#M40928</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-09-25T13:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: If clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227320#M40952</link>
      <description>&lt;P&gt;Logic:&lt;/P&gt;&lt;P&gt;1565 &amp;lt; 1565 &amp;lt; 1565+1565 is equivalent to&amp;nbsp;&lt;/P&gt;&lt;P&gt;1565 &amp;lt; 1565 &amp;lt; 3130 is equivalent to&lt;/P&gt;&lt;P&gt;1565 &amp;lt; 1565 and 1565 &amp;lt; 3130&lt;/P&gt;&lt;P&gt;since 1565 is not &amp;lt; 1565, the result is FALSE&lt;/P&gt;&lt;P&gt;hence "not success".&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 17:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-clause/m-p/227320#M40952</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-09-25T17:52:38Z</dc:date>
    </item>
  </channel>
</rss>

