BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dyrma
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

7 REPLIES 7
Reeza
Super User

You don't have to include anything...

 

define name;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

dyrma
Fluorite | Level 6

I just want to show who is the oldest.

Reeza
Super User

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. 

dyrma
Fluorite | Level 6

Does this mean that proc report can not handle it?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.   

dyrma
Fluorite | Level 6
thanks a lot Reeza and RW9

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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