BookmarkSubscribeRSS Feed
Peter_Y
Calcite | Level 5

Hello:

  I wonder how do you span rows for nested group variables in proc report. The output of the following code

 

ods rtf file='class.rtf';
proc report data=sashelp.class;
column sex age height weight;
define sex / group;
define age/ group;
define height / analysis mean f=8.1;
define weight / analysis mean f=8.1;
run;
ods rtf close;

 

will generate a table like

Sex

Age

Height

Weight

F

11

51.3

50.5

 

12

58.1

80.8

 

13

60.9

91.0

 

14

63.6

96.3

 

15

64.5

112.3

M

11

57.5

85.0

 

12

60.4

103.5

 

13

62.5

84.0

 

14

66.3

107.5

 

15

66.8

122.5

 

16

72.0

150.0

where gender is only display for the first nested age group. However for other age groups, an empty cell (with borders) is still displayed under Sex and I wonder how to either merge gender values with empty cells below or make the top border invisible for empty cells under Sex?

 

Thanks,

Peter

2 REPLIES 2
Ksharp
Super User
You didn't post the output you want to see yet ?


proc report data=sashelp.class nowd;
column sex dummy age height weight;
define sex / group noprint;
define dummy/computed 'sex';
define age/ group;
define height / analysis mean f=8.1;
define weight / analysis mean f=8.1;
compute dummy/length=10 character;
 if not missing(sex) then _sex=sex;
 dummy=_sex;
endcomp;
run;


Ksharp
Super User
proc report data=sashelp.class nowd spanrows;
column sex age height weight;
define sex / group;
define age/ group;
define height / analysis mean f=8.1;
define weight / analysis mean f=8.1;
run;


sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2351 views
  • 0 likes
  • 2 in conversation