The SAS Output Delivery System and reporting techniques

Proc Report define statement

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Proc Report define statement

Hi, everyone

I would like to use proc report to create this output:

 

class.png

 

I'm trying this way:

 

proc report data=sashelp.class;
    column sex name age;
    define sex / group;
    define age / max  'Max. Age';
    define name / ????????;
run;

 

How to define 'name' to receive the output above?

 

Thanks very much for your suggestions.


Accepted Solutions
Solution
‎10-18-2017 04:15 AM
Super User
Super User
Posts: 9,193

Re: Proc Report define statement

It may be possible, with some coding effort, however data processing really isn't the purpose of proc report. Use one of the data summarisation procedures (summary for instance) or you could simply sort the data and take first by group observation.   

View solution in original post


All Replies
Super User
Posts: 22,818

Re: Proc Report define statement

You don't have to include anything...

 

define name;
Super User
Super User
Posts: 9,193

Re: Proc Report define statement

Thats not going to work.  You are summarising data by sex - name has no relevance in this summarisation.  Why should it show Jane and not some other value?  Makes no sense to have name as a column there.

Occasional Contributor
Posts: 5

Re: Proc Report define statement

I just want to show who is the oldest.

Super User
Posts: 22,818

Re: Proc Report define statement

Use PROC SUMMARY with the ID to associate the name with the highest value. You can use PROC REPORT to display the output. 

 

PROC REPORT can summarize data but it's easier outside IMO. 

Occasional Contributor
Posts: 5

Re: Proc Report define statement

Does this mean that proc report can not handle it?

Solution
‎10-18-2017 04:15 AM
Super User
Super User
Posts: 9,193

Re: Proc Report define statement

It may be possible, with some coding effort, however data processing really isn't the purpose of proc report. Use one of the data summarisation procedures (summary for instance) or you could simply sort the data and take first by group observation.   

Occasional Contributor
Posts: 5

Re: Proc Report define statement

thanks a lot Reeza and RW9
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 335 views
  • 1 like
  • 3 in conversation