Stu
Stu

Reputation: 1653

Add minimums to PROC SQL

Somewhat basic question, how can I attach the minimum of another variable in the PROC SQL step? Is there a better way than PROC SQL?

Name   Payment
Tom    30
Tom    45
Tom    15
Bill   20
Bill   100

How could I write a PROC SQL statement that would return the count for each person along with the minimum of "Payment":

Name Number MinPayment
Tom  3      15
Bill 2      20

Upvotes: 1

Views: 57

Answers (1)

Stu Sztukowski
Stu Sztukowski

Reputation: 12909

proc sql;
    select Name
          , count(Name) as Number
          , min(Payment) as MinPayment
    from have
    group by Name
    ;
quit;

Upvotes: 3

Related Questions