BookmarkSubscribeRSS Feed
chouchou
Calcite | Level 5

Hi guys, I want to create a table like this by using PROC REPORT:

             -Gender-         -Gender-

   Age  Female Male  Female Male

Group     SBP  SBP     DBP  DBP

<=50        XX     XX        XX     XX

  >50        XX     XX        XX     XX

The data set I have looks like this:

Gender Age SBP DBP

M 23 144 90

F 68 110 62

M 55 130 80

F 28 120 70

M 35 142 82

M 45 150 96

F 48 138 88

F 78 132 76

My problem is:

I can create a new variable 'Age Group' with values '<=50' and '>50',

but I couldn't group the created 'Age Group' variable.

Can anyone give me some insights? Thank you.

5 REPLIES 5
ballardw
Super User

Show what code you've tried.

data_null__
Jade | Level 19
proc format; value ageg 0-50 = '<= 50' 50-100 = '>50';
  
run;
data bp;
   input Gender:$1. Age SBP DBP;
   cards;
M 23 144 90
F 68 110 62
M 55 130 80
F 28 120 70
M 35 142 82
M 45 150 96
F 48 138 88
F 78 132 76
;;;;
   run;
proc report nowd list;
  
columns age (sbp dbp), gender;
   define age / group format=ageg. order=internal;
   define gender / across;
  
define sbp / mean;
  
define dbp / mean;
  
run;


10-20-2014 6-00-15 PM.png
chouchou
Calcite | Level 5

Hi data_null,

Thank you for your answer, however when I was dealing with this problem, the dataset had already existed, so I was wondering if there is one way to just use proc report, and within the proc report statement to group age values, and achieved the desired result, without using other statements?

data_null__
Jade | Level 19

The user defined value format is independent of the data.

chouchou
Calcite | Level 5

Yes, you're right. But is there a way to group age within the proc report statement?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 925 views
  • 0 likes
  • 3 in conversation