<?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 If statement in SAS Proc in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262513#M51271</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have two question please answer them:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1. Is it true that we can't use if statement in all SAS Procedures? Are there some procedures in which we can use if statement, If yes then please name some of them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Can we use if statement in Proc sql? If yes, then please give me a small example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ramanuj&lt;/P&gt;</description>
    <pubDate>Fri, 08 Apr 2016 16:21:47 GMT</pubDate>
    <dc:creator>Ramanuj_Khatri</dc:creator>
    <dc:date>2016-04-08T16:21:47Z</dc:date>
    <item>
      <title>If statement in SAS Proc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262513#M51271</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have two question please answer them:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1. Is it true that we can't use if statement in all SAS Procedures? Are there some procedures in which we can use if statement, If yes then please name some of them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Can we use if statement in Proc sql? If yes, then please give me a small example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ramanuj&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2016 16:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262513#M51271</guid>
      <dc:creator>Ramanuj_Khatri</dc:creator>
      <dc:date>2016-04-08T16:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in SAS Proc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262515#M51273</link>
      <description>&lt;P&gt;No you can't use IF statements in all procs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you're intending to refer to WHERE statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AFAIK you can use it all procs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHERE is a clause available in SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot use if statement in proc sql. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2016 16:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262515#M51273</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-08T16:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in SAS Proc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262518#M51274</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/75858"&gt;@Ramanuj_Khatri﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Answers:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Examples of procedures which allow the use of an IF statement (in a certain way) include PROC PHREG, &lt;SPAN&gt;PROC &lt;/SPAN&gt;GENMOD, &lt;SPAN&gt;PROC &lt;/SPAN&gt;NLMIXED, &lt;SPAN&gt;PROC &lt;/SPAN&gt;MCMC, &lt;SPAN&gt;PROC &lt;/SPAN&gt;GLIMMIX and some other statistical procedures as well as PROC FCMP.&lt;/LI&gt;
&lt;LI&gt;No, an IF statement is not valid in PROC SQL. If you want to perform, e.g., conditional assignments in PROC SQL, please provide details on your problem.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 08 Apr 2016 16:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262518#M51274</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-08T16:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in SAS Proc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262520#M51275</link>
      <description>&lt;P&gt;WHERE statements should work in all procs. &amp;nbsp;The main exception is PROC SQL which has its own WHERE clause as part of statements like SELECT, DELETE or UPDATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An actual IF/THEN statement is general NOT available in PROCS. &amp;nbsp;There are some procs that allow you to provide snippets of code that will support IF/THEN statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In PROC SQL the type of logic you would use in an IF/THEN statement you would normally code using CASE instead.&lt;/P&gt;
&lt;P&gt;So in a data step you could write:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if sex= 1 then gender='Female';
else if sex=2 then gender='Male';
else gender='Unknown;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In PROC SQL you would write:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when sex=1 then 'Male'
     when sex=2 then 'Female'
     else 'Unknown'
end as Gender&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Apr 2016 16:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262520#M51275</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-04-08T16:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in SAS Proc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262521#M51276</link>
      <description>&lt;P&gt;You can use IF in Proc FCMP (which makes functions calleable in a datastep), Proc Template (in defining some options inside diferent types of templates) , In compute blocks in Proc Report.&lt;/P&gt;
&lt;P&gt;I'm sure there are other places but I don't have every SAS module available.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2016 16:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262521#M51276</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-08T16:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in SAS Proc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262531#M51278</link>
      <description>Thanks Tom, for detailed answer.</description>
      <pubDate>Fri, 08 Apr 2016 17:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-in-SAS-Proc/m-p/262531#M51278</guid>
      <dc:creator>Ramanuj_Khatri</dc:creator>
      <dc:date>2016-04-08T17:02:39Z</dc:date>
    </item>
  </channel>
</rss>

