<?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: Creating a formula column based on available information in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142229#M2256</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you'll end up hard coding things not necessarily. If you have multiple formulas/conditions I'd probably calculate them all, but then use a coalesce to determine which is the final one to keep. The issue then becomes how to keep your log clean, if that's a requirement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Dec 2014 06:29:20 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-12-09T06:29:20Z</dc:date>
    <item>
      <title>Creating a formula column based on available information</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142225#M2252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;suppose I have the following equation:&amp;nbsp; R = A*B, and B = C/D&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and suppose I have the following table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="74" style="border: 1px solid rgb(0, 0, 0); width: 341px; height: 70px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;A&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;B&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;D&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;a1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;b1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;a2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;c2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;d2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the first line I can directly calculate R1 = a1*b1, but in the second line I need to&amp;nbsp; R2 = a2*c2/d2,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so how is it possible to write a code that will choose the right formula depending on the available information?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps: in case all variables are available, choose the "straightest" method, i.e&amp;nbsp; R=A*B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 03:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142225#M2252</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2014-12-09T03:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a formula column based on available information</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142226#M2253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input A B C D;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;2 5 . .&lt;/P&gt;&lt;P&gt;1 . 10 5&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;R=a*coalesce(b,c/d);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 03:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142226#M2253</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-12-09T03:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a formula column based on available information</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142227#M2254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi stat@sas, ran your code and it was good, thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please also show me how to achieve the same result using the IF THEN ELSE procedures because if my actual case will have more variables and more complex equations I guess it will be too messy to put everything into a single COALESCE?&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 04:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142227#M2254</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2014-12-09T04:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a formula column based on available information</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142228#M2255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is an example using &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;IF THEN ELSE statement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if b ne . then R=a*b;&lt;/P&gt;&lt;P&gt;else R=a*c/d;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 05:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142228#M2255</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-12-09T05:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a formula column based on available information</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142229#M2256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you'll end up hard coding things not necessarily. If you have multiple formulas/conditions I'd probably calculate them all, but then use a coalesce to determine which is the final one to keep. The issue then becomes how to keep your log clean, if that's a requirement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 06:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Creating-a-formula-column-based-on-available-information/m-p/142229#M2256</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-12-09T06:29:20Z</dc:date>
    </item>
  </channel>
</rss>

