<?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 Split the dept bonus equally to all employees in that dept in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750670#M236154</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I am learning on SAS. I came across this query. I am not able to find answer for this one. I hope you guys will help me on this with the method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data dept_table;&lt;BR /&gt;input dept_name $ total_bonus ;&lt;BR /&gt;cards;&lt;BR /&gt;IT 50000&lt;BR /&gt;HR 69000&lt;BR /&gt;GL 90000&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;Data Emp_table;&lt;BR /&gt;input dept_name $ emp_id;&lt;BR /&gt;cards;&lt;BR /&gt;IT 1&lt;BR /&gt;IT 2&lt;BR /&gt;IT 3&lt;BR /&gt;IT 4&lt;BR /&gt;IT 5&lt;BR /&gt;HR 23&lt;BR /&gt;HR 45&lt;BR /&gt;HR 86&lt;BR /&gt;GL 96&lt;BR /&gt;GL 52&lt;BR /&gt;GL 25&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to split the total dept bonus to all the employees in that specific dept. I tried but doing so my subquery resulting multiple rows so not getting exact result...&lt;BR /&gt;&lt;BR /&gt;My expected result is&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_el_doredo_0-1624799838755.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60783i465FA93DEF461FC2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_el_doredo_0-1624799838755.png" alt="_el_doredo_0-1624799838755.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;This is the program i tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=dept_table;&lt;BR /&gt;by dept_name;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort data=emp_table;&lt;BR /&gt;by dept_name;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data final;&lt;BR /&gt;merge dept_table(In=A) emp_table(IN=B);&lt;BR /&gt;by dept_name;&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select dept_name,emp_id,(select count(emp_id) from final group by dept_name)&lt;BR /&gt;from final;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you guys can help me on this&lt;/P&gt;</description>
    <pubDate>Sun, 27 Jun 2021 13:17:57 GMT</pubDate>
    <dc:creator>_el_doredo</dc:creator>
    <dc:date>2021-06-27T13:17:57Z</dc:date>
    <item>
      <title>Split the dept bonus equally to all employees in that dept</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750670#M236154</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I am learning on SAS. I came across this query. I am not able to find answer for this one. I hope you guys will help me on this with the method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data dept_table;&lt;BR /&gt;input dept_name $ total_bonus ;&lt;BR /&gt;cards;&lt;BR /&gt;IT 50000&lt;BR /&gt;HR 69000&lt;BR /&gt;GL 90000&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;Data Emp_table;&lt;BR /&gt;input dept_name $ emp_id;&lt;BR /&gt;cards;&lt;BR /&gt;IT 1&lt;BR /&gt;IT 2&lt;BR /&gt;IT 3&lt;BR /&gt;IT 4&lt;BR /&gt;IT 5&lt;BR /&gt;HR 23&lt;BR /&gt;HR 45&lt;BR /&gt;HR 86&lt;BR /&gt;GL 96&lt;BR /&gt;GL 52&lt;BR /&gt;GL 25&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to split the total dept bonus to all the employees in that specific dept. I tried but doing so my subquery resulting multiple rows so not getting exact result...&lt;BR /&gt;&lt;BR /&gt;My expected result is&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_el_doredo_0-1624799838755.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60783i465FA93DEF461FC2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_el_doredo_0-1624799838755.png" alt="_el_doredo_0-1624799838755.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;This is the program i tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=dept_table;&lt;BR /&gt;by dept_name;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort data=emp_table;&lt;BR /&gt;by dept_name;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data final;&lt;BR /&gt;merge dept_table(In=A) emp_table(IN=B);&lt;BR /&gt;by dept_name;&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select dept_name,emp_id,(select count(emp_id) from final group by dept_name)&lt;BR /&gt;from final;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you guys can help me on this&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 13:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750670#M236154</guid>
      <dc:creator>_el_doredo</dc:creator>
      <dc:date>2021-06-27T13:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Split the dept bonus equally to all employees in that dept</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750674#M236155</link>
      <description>&lt;P&gt;This creates the table you want. I didn't do the division of the total bonus divided by the number of employees, I left that out and assign it to you as a homework problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dept_table;
	input dept_name $ total_bonus;
	cards;
IT 50000
HR 69000
GL 90000
;
run;

Data Emp_table;
	input dept_name $ emp_id;
	cards;
IT 1
IT 2
IT 3
IT 4
IT 5
HR 23
HR 45
HR 86
GL 96
GL 52
GL 25
;
run;

proc sql;
	create table want as 
        select a.dept_name, a.emp_id, count(a.emp_id) as count, b.total_bonus from 
		emp_table a left join dept_table b on a.dept_name=b.dept_name 
        group by a.dept_name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Jun 2021 15:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750674#M236155</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-27T15:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Split the dept bonus equally to all employees in that dept</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750677#M236156</link>
      <description>&lt;P&gt;Thank you so much... I tried with the sub query..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select a.dept_name, a.emp_id, count(emp_id) as count, b.total_bonus,&lt;BR /&gt;(b.total_bonus/ calculated count) as bonus from &lt;BR /&gt;emp_table a left join dept_table b on a.dept_name=b.dept_name group by &lt;BR /&gt;a.dept_name;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 15:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750677#M236156</guid>
      <dc:creator>_el_doredo</dc:creator>
      <dc:date>2021-06-27T15:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Split the dept bonus equally to all employees in that dept</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750679#M236157</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366820"&gt;@_el_doredo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much... I tried with the sub query..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select a.dept_name, a.emp_id, count(emp_id) as count, b.total_bonus,&lt;BR /&gt;(b.total_bonus/ calculated count) as bonus from &lt;BR /&gt;emp_table a left join dept_table b on a.dept_name=b.dept_name group by &lt;BR /&gt;a.dept_name;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In the future, please help your self (and help us as well) by indenting your code to improve readability (as I have done in my earlier reply)&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jun 2021 15:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-the-dept-bonus-equally-to-all-employees-in-that-dept/m-p/750679#M236157</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-27T15:36:43Z</dc:date>
    </item>
  </channel>
</rss>

