<?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: SAS coding question-how to code average of highest values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595566#M171362</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265801"&gt;@Amy0223&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;In your input sample set, please include only the variables relevant to the task, as in the sample below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                                                                                                                                                                                                                     
  input id name $ (salary01-salary03) (:comma.) ;                                                                                                                                                                                                               
  cards ;                                                                                                                                                                                                                                                       
 1  Mitchell  22,450  23,000  26,600                                                                                                                                                                                                                            
 2  Miller      .     32,500  33,000                                                                                                                                                                                                                            
 3  Evans     42,900  43,900    .                                                                                                                                                                                                                               
 4  Fair      29,700  32,900  34,500                                                                                                                                                                                                                            
 5  Meyers    33,700  34,400  37,000                                                                                                                                                                                                                            
 6  Rogers    27,000  27,800    .                                                                                                                                                                                                                               
 7  Anderson  33,000  35,100  36,000                                                                                                                                                                                                                            
10  Baxter    23,900    .     31,300                                                                                                                                                                                                                            
11  Wood      33,000  34,000  35,700                                                                                                                                                                                                                            
12  Wheeler   31,500  33,200  35,600                                                                                                                                                                                                                            
13  Hancock   21,000    .     22,500                                                                                                                                                                                                                            
14  Looney    42,900  36,200  37,800                                                                                                                                                                                                                            
15  Fry       29,700  30,500  31,200                                                                                                                                                                                                                            
;                                                                                                                                                                                                                                                               
run ;                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                
data want ;                                                                                                                                                                                                                                                     
  set have ;                                                                                                                                                                                                                                                    
  mean = mean (largest (1, of salary:), largest (2, of salary:)) ;                                                                                                                                                                                              
run ;                                                                
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The LARGEST function ignores missing values, so there's no need for any extra "two-three" logic. For the first argument, 1 means "first largest" and 2 means "second largest".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Oct 2019 21:01:38 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2019-10-10T21:01:38Z</dc:date>
    <item>
      <title>SAS coding question-how to code average of highest values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595529#M171342</link>
      <description>&lt;P&gt;Hi, I'm not sure how to code this SAS problem below. Any help is greatly appreciated. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Calculate the average of the two highest salaries for employees who have three salaries and average of two salaries if they have only two salaries.&amp;nbsp;Print the names of employees who have the highest average in their department.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;         Employee_id   Name gender   years   dept     salary01 salary02  salary03;
		 
                 1 Mitchell, Jane A  f    6     shoe     22,450  23,000  26,600
		 2 Miller, Frances T  f  8  appliance      .     32,500  33,000
		 3 Evans, Richard A  m   9  appliance    42,900  43,900  .
		 4 Fair, Suzanne K  f    3  clothing     29,700  32,900 34,500
		 5 Meyers, Thomas D  m  5  appliance     33,700  34,400  37,000
		 6 Rogers, Steven F  m  3    shoe         27,000  27,800  .
		 7 Anderson, Frank F  m  5  clothing      33,000  35,100  36,000
		10 Baxter, David T  m  2     shoe         23,900    .    31,300
		11 Wood, Brenda L  f  3     clothing      33,000  34,000  35,700
		12 Wheeler, Vickie M  f  7  appliance     31,500  33,200  35,600
		13 Hancock, Sharon T  f  1  clothing      21,000   .     22,500
		14 Looney, Roger M    m  10 appliance     42,900 36,200 37,800
		15 Fry, Marie E     f    6  clothing      29,700 30,500 31,200&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Oct 2019 23:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595529#M171342</guid>
      <dc:creator>Amy0223</dc:creator>
      <dc:date>2019-10-10T23:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS question-how to code average of highest values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595533#M171346</link>
      <description>&lt;P&gt;You could use CALL SORTN to make sure that the two highest values are always in variables salary02 and salary03, and then average salary02 and salary03.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0exzteatvicqkn1bzyzs0qaecy1.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0exzteatvicqkn1bzyzs0qaecy1.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 18:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595533#M171346</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-10T18:39:37Z</dc:date>
    </item>
    <item>
      <title>SAS question-how to code average of highest values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595553#M171356</link>
      <description>&lt;P&gt;I don't know why the title was changed by either original author or a moderator, but the title "SAS coding question" is a relatively meaningless title (almost every question in the forum could be titled "SAS coding question"); originally it was "&lt;SPAN&gt;SAS question-how to code average of highest values", a much more meaningful and specific title, that cannot apply to almost every question in the forum.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;No one benefits from meaningless titles. Everyone benefits from meaningful titles. Whoever changed the title, please change it back.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 20:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595553#M171356</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-10T20:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS coding question-how to code average of highest values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595566#M171362</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265801"&gt;@Amy0223&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;In your input sample set, please include only the variables relevant to the task, as in the sample below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                                                                                                                                                                                                                     
  input id name $ (salary01-salary03) (:comma.) ;                                                                                                                                                                                                               
  cards ;                                                                                                                                                                                                                                                       
 1  Mitchell  22,450  23,000  26,600                                                                                                                                                                                                                            
 2  Miller      .     32,500  33,000                                                                                                                                                                                                                            
 3  Evans     42,900  43,900    .                                                                                                                                                                                                                               
 4  Fair      29,700  32,900  34,500                                                                                                                                                                                                                            
 5  Meyers    33,700  34,400  37,000                                                                                                                                                                                                                            
 6  Rogers    27,000  27,800    .                                                                                                                                                                                                                               
 7  Anderson  33,000  35,100  36,000                                                                                                                                                                                                                            
10  Baxter    23,900    .     31,300                                                                                                                                                                                                                            
11  Wood      33,000  34,000  35,700                                                                                                                                                                                                                            
12  Wheeler   31,500  33,200  35,600                                                                                                                                                                                                                            
13  Hancock   21,000    .     22,500                                                                                                                                                                                                                            
14  Looney    42,900  36,200  37,800                                                                                                                                                                                                                            
15  Fry       29,700  30,500  31,200                                                                                                                                                                                                                            
;                                                                                                                                                                                                                                                               
run ;                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                
data want ;                                                                                                                                                                                                                                                     
  set have ;                                                                                                                                                                                                                                                    
  mean = mean (largest (1, of salary:), largest (2, of salary:)) ;                                                                                                                                                                                              
run ;                                                                
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The LARGEST function ignores missing values, so there's no need for any extra "two-three" logic. For the first argument, 1 means "first largest" and 2 means "second largest".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 21:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595566#M171362</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-10T21:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS coding question-how to code average of highest values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595577#M171370</link>
      <description>Thank you so much! I greatly appreciate your kind help!</description>
      <pubDate>Thu, 10 Oct 2019 22:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595577#M171370</guid>
      <dc:creator>Amy0223</dc:creator>
      <dc:date>2019-10-10T22:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS coding question-how to code average of highest values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595586#M171376</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265801"&gt;@Amy0223&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then may-be mark the answer that helped you the most as solution - and eventually also give likes to answers that were helpful.&lt;/P&gt;
&lt;P&gt;By marking an answer as solution your question gets "ticked-off" so people can already see in the overview list that it's resolved. Plus: It's also giving someone the credit for spending time for you and providing a solution.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 23:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-coding-question-how-to-code-average-of-highest-values/m-p/595586#M171376</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-10T23:03:43Z</dc:date>
    </item>
  </channel>
</rss>

