<?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: Translating sumif excel code into sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767392#M243286</link>
    <description>&lt;P&gt;Here is the code that does the job&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select sum(M) into :sum_m from have
where M&amp;gt;= 3;
quit;

data want;
set have;
if M &amp;gt; 3 then do
new_var=round((40000/input(&amp;amp;sum_m,best12.))*M,3);
end;
else new_var=0;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output is as follows and matches the values in your excel sheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_1-1631535968162.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63534i622D15641B96FA2A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_1-1631535968162.png" alt="Sajid01_1-1631535968162.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if there are questions.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Sep 2021 12:26:27 GMT</pubDate>
    <dc:creator>Sajid01</dc:creator>
    <dc:date>2021-09-13T12:26:27Z</dc:date>
    <item>
      <title>Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767343#M243275</link>
      <description>&lt;P&gt;Hi, i need help in translating the below excel code into SAS code..please note that the &lt;STRONG&gt;M = final_score(Contains 7 rows with scores from 0 to 5) and N2 = Total_Amount( 40 000)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;(IF(M2&amp;gt;=3,$N$2/SUMIF($M$1:$M$7,"&amp;gt;=3")*M2,0)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking forward to your help.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 09:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767343#M243275</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2021-09-13T09:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767365#M243277</link>
      <description>&lt;PRE&gt;SUMIF($M$1:$M$7,"&amp;gt;=3")*M2,0&lt;/PRE&gt;
&lt;P&gt;Can you please verify if the above is correct?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 11:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767365#M243277</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-09-13T11:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767367#M243279</link>
      <description>Hi thanks for your reply, apologies we should replace M2 with only M&lt;BR /&gt;SUMIF($M$1:$M$7,"&amp;gt;=3")*M,0</description>
      <pubDate>Mon, 13 Sep 2021 11:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767367#M243279</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2021-09-13T11:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767370#M243280</link>
      <description>&lt;P&gt;Please help understand this term&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;$N$2/SUMIF($M$1:$M$7,"&amp;gt;=3")*M&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Looking at denominator, if the sum of the seven rows is greater or equal to 3, use the sum of the rows and multiply by M.&lt;BR /&gt;Does that mean multiply every member of every row (M! to M7) with the Sum.&lt;BR /&gt;IF the sum is less than 3, then does it not mean zero in the denominator ("Division by zero").&lt;BR /&gt;Please attach a sample spreadsheet.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 11:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767370#M243280</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-09-13T11:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767371#M243281</link>
      <description>&lt;P&gt;What does the data look like?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where's the single N2 value stored if you have 7 observations?&lt;/P&gt;
&lt;P&gt;Show us a &lt;EM&gt;before&lt;/EM&gt; table (as SAS code) and a &lt;EM&gt;wanted&lt;/EM&gt; table.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 11:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767371#M243281</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-09-13T11:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767378#M243282</link>
      <description>&lt;P&gt;Hi, I have attached excel spreadsheet as per your request&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 12:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767378#M243282</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2021-09-13T12:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767392#M243286</link>
      <description>&lt;P&gt;Here is the code that does the job&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select sum(M) into :sum_m from have
where M&amp;gt;= 3;
quit;

data want;
set have;
if M &amp;gt; 3 then do
new_var=round((40000/input(&amp;amp;sum_m,best12.))*M,3);
end;
else new_var=0;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output is as follows and matches the values in your excel sheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_1-1631535968162.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63534i622D15641B96FA2A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_1-1631535968162.png" alt="Sajid01_1-1631535968162.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if there are questions.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 12:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767392#M243286</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-09-13T12:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767393#M243287</link>
      <description>&lt;P&gt;Hi Chris, see below sas code as per your request..the total amount variable is defined as macro variable..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let Total_Amount= 40000;



data HAVE;
input Final_Score user : $20.;
datalines;
3 ALUPIYA
2 DLOUIS
5 DMORAKE
4 FDANISA
1 FFARAO
2 SSEBELA
4 WSMITH
;



data WANT;
input Final_Score user : $20. Amount;
datalines;
3 ALUPIYA 7500
2 DLOUIS 0
5 DMORAKE 12500
4 FDANISA 10000
1 FFARAO 0
2 SSEBELA 0
4 WSMITH 10000
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 12:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767393#M243287</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2021-09-13T12:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767396#M243288</link>
      <description>Thanks a lot!!</description>
      <pubDate>Mon, 13 Sep 2021 12:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767396#M243288</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2021-09-13T12:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Translating sumif excel code into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767398#M243289</link>
      <description>&lt;P&gt;Sorry in the morning rush I missed the first step of the code. That I am presenting below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input M;
datalines;
3.20
2.00
4.00
1.00
5.00
2.00
4.00
5.00
2.00
1.00
3.50
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Sep 2021 12:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Translating-sumif-excel-code-into-sas/m-p/767398#M243289</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-09-13T12:45:20Z</dc:date>
    </item>
  </channel>
</rss>

