BookmarkSubscribeRSS Feed
Amy0223
Quartz | Level 8

Hi, I'm new to SAS and I'm struggling with this homework problem below. Any help is greatly appreciated! Thank you.

 

  1. For each department find the employee whose salary01 is the highest in the department. Print the names of these employees and department names.
             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
4 REPLIES 4
PaigeMiller
Diamond | Level 26

Sort the data by dept and salary, then (since this puts the highest salary01 in the last record of each department) and then select the last record via:

 

 

data want;
    set have;
    by dept;
    if last.dept;
run;
--
Paige Miller
Reeza
Super User

I suspect you're expected to use the techniques taught in class and there are many many ways to do this one. 

 

http://support.sas.com/documentation/cdl/en/procstat/66703/HTML/default/viewer.htm#procstat_univaria...

 


@Amy0223 wrote:

Hi, I'm new to SAS and I'm struggling with this homework problem below. Any help is greatly appreciated! Thank you.

 

  1. For each department find the employee whose salary01 is the highest in the department. Print the names of these employees and department names.
             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

 

Amy0223
Quartz | Level 8
Thank you very much for the link.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 832 views
  • 2 likes
  • 4 in conversation