<?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: How to do calculation with two rows selected? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133052#M36161</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I just got the correct answer from PG. Thanks a lot~&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Mar 2013 15:00:32 GMT</pubDate>
    <dc:creator>Phoenix8527</dc:creator>
    <dc:date>2013-03-13T15:00:32Z</dc:date>
    <item>
      <title>How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133044#M36153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is my table. I want to get the result group by Tenure. Percentage=1-(No Change,N/(Sum-Not Found,N)) e.g. for NBUS Percentage=1-(250/(517-146)), for Season Percentage=1-(917/(2028-680))&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="369"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl69" height="20" style="font-family: Calibri; background: #4f81bd; color: white; font-size: 11pt; font-weight: bold; border: windowtext 0.5pt solid;" width="65"&gt;Tenure&lt;/TD&gt;&lt;TD class="xl70" style="font-family: Calibri; background: #4f81bd; color: white; font-size: 11pt; font-weight: bold; border: windowtext 0.5pt solid;" width="112"&gt;Status_Change&lt;/TD&gt;&lt;TD class="xl70" style="font-family: Calibri; background: #4f81bd; color: white; font-size: 11pt; font-weight: bold; border: windowtext 0.5pt solid;" width="64"&gt;Status&lt;/TD&gt;&lt;TD class="xl70" style="font-family: Calibri; background: #4f81bd; color: white; font-size: 11pt; font-weight: bold; border: windowtext 0.5pt solid;" width="64"&gt;Count&lt;/TD&gt;&lt;TD class="xl71" style="font-family: Calibri; background: #4f81bd; color: white; font-size: 11pt; font-weight: bold; border: windowtext 0.5pt solid;" width="64"&gt;Sum&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;NBUS&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Change&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;N&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;95&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;517&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;NBUS&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;No Change&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;N&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;250&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;517&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;NBUS&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Not Found&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;N&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;146&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;517&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;NBUS&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Change&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Y&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;517&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;NBUS&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;No Change&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Y&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;23&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;517&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;NBUS&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Not Found&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Y&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;6&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;517&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Season&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Change&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;N&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;309&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;2028&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Season&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;No Change&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;N&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;971&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;2028&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Season&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Not Found&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;N&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;680&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;2028&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Season&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Change&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Y&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;2028&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Season&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;No Change&lt;/TD&gt;&lt;TD class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Y&lt;/TD&gt;&lt;TD align="right" class="xl66" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;35&lt;/TD&gt;&lt;TD align="right" class="xl68" style="font-family: Calibri; background: #dce6f1; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;2028&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl72" height="20" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Season&lt;/TD&gt;&lt;TD class="xl73" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Not Found&lt;/TD&gt;&lt;TD class="xl73" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;Y&lt;/TD&gt;&lt;TD align="right" class="xl73" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;31&lt;/TD&gt;&lt;TD align="right" class="xl74" style="font-family: Calibri; color: black; font-size: 11pt; font-weight: 400; border: windowtext 0.5pt solid;"&gt;2028&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Here is my code, it has ERROR: Subquery evaluated to more than one row.&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table table2 as select *, Sum(Count) as Sum from table1 group by Tenure;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table table3 as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select Count/(select&amp;nbsp; (Sum-Count) as Dif from table2 where Status='N' and Status_Change='Not Found') from table2 where Status='N' and Status_Change='No Change';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 21:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133044#M36153</guid>
      <dc:creator>Phoenix8527</dc:creator>
      <dc:date>2013-03-12T21:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133045#M36154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you're grouping by tenure and status?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.tenure,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,t1.status,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 - (sum(case when status_change='No Change' then N else 0 end)/(sum(n) - sum(case when status_change='Not Found' then n else 0 end))&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table1 t1&lt;/P&gt;&lt;P&gt;group by t1.tenure, t1.status;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 22:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133045#M36154</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-03-12T22:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133046#M36155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Partial understanding of what you want leads me to suggest :&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;select &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C.tenure, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 - C.count/(S.sum-S.count) as percentage format=percent7.1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;from have as C inner join have as S &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on C.tenure=S.tenure&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;where &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(C.status_change) = "NO CHANGE" and C.status='N' and&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(S.status_change) = "NOT FOUND" and S.status='N';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 22:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133046#M36155</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-03-12T22:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133047#M36156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to my understanding.....&lt;/P&gt;&lt;P&gt;This solution will help....if there is only one status_change as notfound or nochange....&lt;/P&gt;&lt;P&gt;Note: Take your dataset instead of &lt;STRONG&gt;a&lt;/STRONG&gt;.....and do adjust &lt;STRONG&gt;notfound&lt;/STRONG&gt; and &lt;STRONG&gt;nochange&lt;/STRONG&gt; accordingly.(not found or no change).....or use UPCASE....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro demo();&lt;BR /&gt;data k;&lt;BR /&gt;&amp;nbsp; set &lt;STRONG&gt;a&lt;/STRONG&gt;;&lt;BR /&gt;&amp;nbsp; dif=sum-count;&lt;BR /&gt;&amp;nbsp; if status_change in ('&lt;STRONG&gt;Nochange&lt;/STRONG&gt;','&lt;STRONG&gt;Notfound&lt;/STRONG&gt;');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data percent(keep=percentage tenure);&lt;BR /&gt;&amp;nbsp; set k;&lt;BR /&gt;&amp;nbsp; if status_change='&lt;STRONG&gt;Nochange&lt;/STRONG&gt;' then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('temp',trim(left(count)));&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if status_change='&lt;STRONG&gt;Notfound&lt;/STRONG&gt;' then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; percentage = (symget('temp'))/trim(left(dif));&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; if percentage&amp;gt;0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;BR /&gt;%demo();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can calculate percentage accordingly....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 11:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133047#M36156</guid>
      <dc:creator>anshulgoel</dc:creator>
      <dc:date>2013-03-13T11:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133048#M36157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply. I got an error message like this "ERROR: Ambiguous reference, column Tenure is in more than one table."&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 13:51:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133048#M36157</guid>
      <dc:creator>Phoenix8527</dc:creator>
      <dc:date>2013-03-13T13:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133049#M36158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would you please post your code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 13:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133049#M36158</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-03-13T13:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133050#M36159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Linlin,&lt;/P&gt;&lt;P&gt;Here is my code, it has ERROR: Subquery evaluated to more than one row.&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table table2 as select *, Sum(Count) as Sum from table1 group by Tenure;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table table3 as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select Count/(select&amp;nbsp; (Sum-Count) as Dif from table2 where Status='N' and Status_Change='Not Found') from table2 where Status='N' and Status_Change='No Change';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 14:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133050#M36159</guid>
      <dc:creator>Phoenix8527</dc:creator>
      <dc:date>2013-03-13T14:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133051#M36160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does PG's code give you what you want?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input Tenure :$6. Status_Change :&amp;amp;$9. Status $1.Count sum;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;NBUS Change&amp;nbsp; N 95 517&lt;/P&gt;&lt;P&gt;NBUS No Change&amp;nbsp; N 250 517&lt;/P&gt;&lt;P&gt;NBUS Not Found&amp;nbsp; N 146 517&lt;/P&gt;&lt;P&gt;NBUS Change&amp;nbsp; Y 0 517&lt;/P&gt;&lt;P&gt;NBUS No Change&amp;nbsp; Y 23 517&lt;/P&gt;&lt;P&gt;NBUS Not Found&amp;nbsp; Y 6 517&lt;/P&gt;&lt;P&gt;Season Change&amp;nbsp; N&amp;nbsp; 309 2028&lt;/P&gt;&lt;P&gt;Season No Change&amp;nbsp; N 971 2028&lt;/P&gt;&lt;P&gt;Season Not Found&amp;nbsp; N 680 2028&lt;/P&gt;&lt;P&gt;Season Change&amp;nbsp; Y 2 2028&lt;/P&gt;&lt;P&gt;Season No Change&amp;nbsp; Y 35 2028&lt;/P&gt;&lt;P&gt;Season Not Found&amp;nbsp; Y 31 2028&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;select &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C.tenure, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 - C.count/(S.sum-S.count) as percentage format=percent7.1&lt;/P&gt;&lt;P&gt;from have as C inner join have as S &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on C.tenure=S.tenure&lt;/P&gt;&lt;P&gt;where &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(C.status_change) = "NO CHANGE" and C.status='N' and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(S.status_change) = "NOT FOUND" and S.status='N';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; Tenure&amp;nbsp;&amp;nbsp;&amp;nbsp; percentage&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NBUS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 32.6%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Season&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28.0%&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 14:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133051#M36160</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-03-13T14:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to do calculation with two rows selected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133052#M36161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I just got the correct answer from PG. Thanks a lot~&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 15:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-do-calculation-with-two-rows-selected/m-p/133052#M36161</guid>
      <dc:creator>Phoenix8527</dc:creator>
      <dc:date>2013-03-13T15:00:32Z</dc:date>
    </item>
  </channel>
</rss>

