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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 7 replies
  • 1207 views
  • 1 like
  • 3 in conversation