LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 14 Mar 2002 14:14:11 -0500
Reply-To:     Nicholson Warman <newarman@OFFICE.UNCG.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nicholson Warman <newarman@OFFICE.UNCG.EDU>
Subject:      Re: DO LOOP Problem
Comments: To: Hamani.Elmaache@CCRA-ADRC.GC.CA
Content-Type: text/plain; charset=US-ASCII

TO: Hamani Elmaache

Rather than the final data step and print, you could use either PROC MEANS/SUMMARY or PROC SQL; I've included the PROC SQL to do what I think you want to achieve.

PROC SQL; select distinct job_code, min(annual_rate) as min_annual_rate label="Min Annual Rate", max(annual_rate) as max_annual_rate label="Max Annual Rate" from work.xx1 group by job_code;

If you want to list each Annual_Rate as well, then make the above a VIEW (create view work.myview as), and merge the work.xx1 with this view by Job_Code.

HTH

====================

Nicholson Warman Data Analysis Consultant Instructional, Research, and Client Services Bryan Building Room 235A University of North Carolina at Greensboro (336) 334-5350 (336) 334-4367 [fax]

>>> "Elmaache, Hamani" <Hamani.Elmaache@CCRA-ADRC.GC.CA> 2002-03-14 13:57:58 >>> Hi there. I have the data: Job_code Annual_Rate;

0010 18000.00 0010 10000.00 0010 20000.00 0010 15000.00 0011 8000.00 0011 12000.00 0012 15000.00

I would have max and min for each Job_code, like this:

max_ min_ Annual_ Rate_ Rate_ Obs Job_code Rate code code

1 10 10000 20000 10000 2 11 12000 12000 8000 3 12 15000 15000 15000

I wrote the following code, but It doesn't work. What's wrong? /**************************/ data xx1; input Job_code Annual_Rate; datalines; 0010 18000.00 0010 10000.00 0010 20000.00 0010 15000.00 0011 8000.00 0011 12000.00 0012 15000.00 ; run;

proc sort data=xx1 out=xx2; by Job_code ; run; /**************************/ data xx3 ; retain Job_code max_Rate_code n; set xx2 ; by Job_code ; max_Rate_code=0; do n = 1 until (last.Job_code) ; if Annual_Rate> max_Rate_code then do; max_Rate_code=Annual_Rate; end; output; end; run;

proc print data=xx3; run; /**********************************/ Thanks a lot. Barrere.


Back to: Top of message | Previous page | Main SAS-L page