<?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: Replacing Excel Formula in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537204#M147693</link>
    <description>Can you unchain those IFs to make it more legible? A series of IF/THEN statements would be significantly easier to manage. SAS doesn't have IF as you're attempting to use there. It does have IFN/IFC.</description>
    <pubDate>Wed, 20 Feb 2019 20:58:08 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-02-20T20:58:08Z</dc:date>
    <item>
      <title>Replacing Excel Formula in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537196#M147689</link>
      <description>&lt;P&gt;I am trying to convert an excel formula into sas and currently struggling.&amp;nbsp; The excel formula is&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;=IF(H11&amp;lt;0,IF(NORMSDIST(H11)&amp;lt;0.0001,"&amp;lt;.0001",NORMSDIST(H11)),IF(1-NORMSDIST(H11)&amp;lt;0.0001,"&amp;lt;.0001",1-NORMSDIST(H11)))


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I am trying to convert this to SAS and H11 equals a field called TSTAT.. I believe I am to use PROBNORM but cant figure out the if part.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if(T1.TSTAT &amp;lt;0,if (PROBNORM(T1.TSTAT) &amp;lt;0.0001,"&amp;lt;.0001",PROBNORM(T1.TSTAT)),if (1-PROBNORM(T1.TSTAT)&amp;lt;0.0001,"&amp;lt;.0001",1-PROBNORM(T1.TSTAT)))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Feb 2019 20:51:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537196#M147689</guid>
      <dc:creator>asherer</dc:creator>
      <dc:date>2019-02-20T20:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing Excel Formula in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537204#M147693</link>
      <description>Can you unchain those IFs to make it more legible? A series of IF/THEN statements would be significantly easier to manage. SAS doesn't have IF as you're attempting to use there. It does have IFN/IFC.</description>
      <pubDate>Wed, 20 Feb 2019 20:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537204#M147693</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-20T20:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing Excel Formula in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537210#M147696</link>
      <description>&lt;P&gt;So My excel code reads&lt;/P&gt;&lt;PRE&gt;=IF(H11&amp;lt;0,
IF(NORMSDIST(H11)&amp;lt;0.0001,"&amp;lt;.0001",NORMSDIST(H11)),
IF(1-NORMSDIST(H11)&amp;lt;0.0001,"&amp;lt;.0001",1-NORMSDIST(H11)))

&lt;/PRE&gt;&lt;P&gt;I would want to replace the&amp;nbsp; IF to&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IFC(T1.TSTAT&amp;lt;0,
IFC(PROBNORM(T1.TSTAT)&amp;lt;0.0001, then ‘&amp;lt;.0001’ PROBNORM(T1.TSTAT)),
IFC(1-PROBNORM(T1.TSTAT)&amp;lt;0.0001,"&amp;lt;.0001",1-PROBNORM(T1.TSTAT)))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or how would I go about changing it to more of a series of ifs and then?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 21:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537210#M147696</guid>
      <dc:creator>asherer</dc:creator>
      <dc:date>2019-02-20T21:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing Excel Formula in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537218#M147699</link>
      <description>Pretty sure that code isn't correct, and I would recommend checking it thoroughly. There definitely shouldn't be any 'THEN' in it. &lt;BR /&gt;</description>
      <pubDate>Wed, 20 Feb 2019 21:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537218#M147699</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-20T21:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing Excel Formula in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537370#M147791</link>
      <description>&lt;P&gt;I did not mean to put it was the correct answer&amp;nbsp; the code I put was not correct. I will attempt to use what you had posted.. Thank you again for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;p_value = probnorm(tstat);

if p_value &amp;lt; 0 then Display = "&amp;lt;0.0000";
else if p_value  &amp;lt; 0.0001 then Display = "&amp;lt;0.0001";
else if p_value &amp;lt; 0.001 then Display = "&amp;lt;0.001";
else Display = "CHECKME";
Assuming you're using a data step, the following is likely what you want. There's also a format approach that can be handy:
 
SAS also has a defined PVALUE format:, anything less than 0.0001 is coded as &amp;lt;0.0001 and other values show up as their calculated values. 
 
data demo;
do pvalue = 0 to 0.1 by 0.0005;
output;
end;
format pvalue pvalue12.4;
run;
@asherer wrote:
So My excel code reads
=IF(H11&amp;lt;0,
IF(NORMSDIST(H11)&amp;lt;0.0001,"&amp;lt;.0001",NORMSDIST(H11)),
IF(1-NORMSDIST(H11)&amp;lt;0.0001,"&amp;lt;.0001",1-NORMSDIST(H11)))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 12:43:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-Excel-Formula-in-SAS/m-p/537370#M147791</guid>
      <dc:creator>asherer</dc:creator>
      <dc:date>2019-02-21T12:43:56Z</dc:date>
    </item>
  </channel>
</rss>

