Hi,
I have a question regards to ACROSS option in PROC REPORT.
I did some modification on sashelp.class as an example.
Please run below code to get the dataset and report.
Is it possible to only change the column width of column "Height"?
How to give a different width for val under the last ACROSS option.
Thanks!
proc sql;
create table class as
select a.*, ifc(age ge 13, '>=13' , '<13') as age_grp ,'Weight' as ept
from sashelp.class(drop=height rename=(weight=val)) as a
union
select b.*, ifc(age ge 13, '>=13' , '<13') as age_grp, 'Height' as ept
from sashelp.class(drop=weight rename=(height=val)) as b;
quit;
proc report data=class nowd headline headskip split='\' spacing=2 missing ;
column name age_grp,Sex,ept,val dummy;
define name/group;
define age_grp/'' across order=data ;
define Sex/'' across order=data ;
define ept/ '' across order=data width=10;
define val/'' display left width=6;
define dummy/ noprint;
compute dummy;
dummy = 1;
endcomp;
run;
Hi:
You mean like this:
It is far easier than your approach. You do NOT need to perform the manipulations in the DATA step that you did. Just a simple user-defined format for AGE. Then you can have numeric variables HEIGHT and WEIGHT under AGE and SEX as ACROSS items. Which means that you can use a simple STYLE(COLUMN) override for width, as shown below:
proc format;
value agef low-12 = '<13'
13-high='>=13';
run;
proc report data=sashelp.class nowd split='\' missing ;
title 'Across';
column name age,Sex,(height weight);
define name/group ;
define age /'' across order=data f=agef.;
define Sex/'' across order=data ;
define height/ sum style(column)={cellwidth=1.5in} ;
define weight/ sum style(column)={cellwidth=.5in};
define dummy/ noprint;
run;
With this approach, the values for HEIGHT and WEIGHT each have their own DEFINE statement, so it is easy to alter the width.
I did change your code, you didn't need the DUMMY variable and in addition, I eliminated the LISTING only options, like HEADLINE and HEADSKIP and SPACING.
Cynthia
Hi:
You mean like this:
It is far easier than your approach. You do NOT need to perform the manipulations in the DATA step that you did. Just a simple user-defined format for AGE. Then you can have numeric variables HEIGHT and WEIGHT under AGE and SEX as ACROSS items. Which means that you can use a simple STYLE(COLUMN) override for width, as shown below:
proc format;
value agef low-12 = '<13'
13-high='>=13';
run;
proc report data=sashelp.class nowd split='\' missing ;
title 'Across';
column name age,Sex,(height weight);
define name/group ;
define age /'' across order=data f=agef.;
define Sex/'' across order=data ;
define height/ sum style(column)={cellwidth=1.5in} ;
define weight/ sum style(column)={cellwidth=.5in};
define dummy/ noprint;
run;
With this approach, the values for HEIGHT and WEIGHT each have their own DEFINE statement, so it is easy to alter the width.
I did change your code, you didn't need the DUMMY variable and in addition, I eliminated the LISTING only options, like HEADLINE and HEADSKIP and SPACING.
Cynthia
Thanks, Cynthia!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.