<?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: finding maximum salary in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/finding-maximum-salary/m-p/810977#M319851</link>
    <description>&lt;P&gt;A reasonable solution to this problem is a hash object:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have0;
LENGTH emp_id 8 name $ 1 dept $ 10 sal 8 manager_id 8;
input emp_id  name $  dept $  sal  manager_id;
datalines;
1       A      HR         200   2
2       B      Fin        300   3
3       C      analytics  400   4
4       D      QA         100   1
;
run;


data want;
  set have0   have0 (obs=0 rename=(sal=_mgr_sal));
  if _n_=1 then do;    
    declare hash h (dataset:'have0 (keep=sal emp_id rename=(emp_id=manager_id sal=_mgr_sal)');
      h.definekey('manager_id');
      h.definedata('_mgr_sal');
      h.definedone();
  end;
  if h.find()=0 and sal&amp;gt;_mgr_sal;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The reason for the second HAVE0 in the SET statement is just to prompt the SAS compiler to allocate a place in the program data vector for the variable _mgr_sal.&amp;nbsp; Mentioning it in the DECLARE statement is not sufficient.&amp;nbsp; But notice the second HAVE0 has "obs=0" so no extra data is generated.&lt;/P&gt;</description>
    <pubDate>Sun, 01 May 2022 22:34:08 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-05-01T22:34:08Z</dc:date>
    <item>
      <title>finding maximum salary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-maximum-salary/m-p/810954#M319833</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;I have below table. I need to find out employee names whose salary is greater than his manager&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;emp_id&amp;nbsp; name&amp;nbsp; &amp;nbsp;dept&amp;nbsp; &amp;nbsp;sal&amp;nbsp; &amp;nbsp;manager_id&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;HR&amp;nbsp; &amp;nbsp; &amp;nbsp;200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;BR /&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Fin&amp;nbsp; &amp;nbsp; &amp;nbsp;300&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;BR /&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;anaytics&amp;nbsp; 400&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;BR /&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; QA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 19:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-maximum-salary/m-p/810954#M319833</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2022-05-01T19:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: finding maximum salary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-maximum-salary/m-p/810966#M319843</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have0;
LENGTH emp_id 8 name $ 1 dept $ 10 sal 8 manager_id 8;
input emp_id  name $  dept $  sal  manager_id;
datalines;
1       A      HR         200   2
2       B      Fin        300   3
3       C      analytics  400   4
4       D      QA         100   1
;
run;

PROC SQL noprint;
 create table have1 as
 select t1.* , t2.sal as sal_mgr
 from   work.have0                  as t1
      , work.have0(keep=emp_id sal) as t2
 where t1.manager_id = t2.emp_id
 order by t1.emp_id , t1.name
;
QUIT;

data want;
 set have1;
 where sal &amp;gt; sal_mgr;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 21:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-maximum-salary/m-p/810966#M319843</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-05-01T21:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: finding maximum salary</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-maximum-salary/m-p/810977#M319851</link>
      <description>&lt;P&gt;A reasonable solution to this problem is a hash object:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have0;
LENGTH emp_id 8 name $ 1 dept $ 10 sal 8 manager_id 8;
input emp_id  name $  dept $  sal  manager_id;
datalines;
1       A      HR         200   2
2       B      Fin        300   3
3       C      analytics  400   4
4       D      QA         100   1
;
run;


data want;
  set have0   have0 (obs=0 rename=(sal=_mgr_sal));
  if _n_=1 then do;    
    declare hash h (dataset:'have0 (keep=sal emp_id rename=(emp_id=manager_id sal=_mgr_sal)');
      h.definekey('manager_id');
      h.definedata('_mgr_sal');
      h.definedone();
  end;
  if h.find()=0 and sal&amp;gt;_mgr_sal;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The reason for the second HAVE0 in the SET statement is just to prompt the SAS compiler to allocate a place in the program data vector for the variable _mgr_sal.&amp;nbsp; Mentioning it in the DECLARE statement is not sufficient.&amp;nbsp; But notice the second HAVE0 has "obs=0" so no extra data is generated.&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 22:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-maximum-salary/m-p/810977#M319851</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-05-01T22:34:08Z</dc:date>
    </item>
  </channel>
</rss>

