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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  You mean like this:

diff_width_under_across.png

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

 

 

 

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  You mean like this:

diff_width_under_across.png

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

 

 

 

Coooooo_Lee
Obsidian | Level 7

Thanks, Cynthia!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

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.

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
  • 2 replies
  • 1567 views
  • 0 likes
  • 2 in conversation