The SAS Output Delivery System and reporting techniques

proc report spanning 2 of 4 columns in header

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

proc report spanning 2 of 4 columns in header

I'm using 9.4 and the output is pdf. In the first example I want the "Outcomes" to span and center over the first two columns. My code is

 

PROC REPORT DATA =NEW_BORN_METRICS nowd spanrows
	style(report)=[rules=all] 
	style(header)=[rules=all cellheight=.6in font_size=1 background=lightgrey]
	style(column)=[font_size=1];
/*	COLUMN ('Outcomes' (Question  Response total_cases Total_Per)) ;*/
/*	COLUMN ('Outcomes' (Question  Response) (total_cases Total_Per)) ;*/
	COLUMN ('Outcomes' (Question  Response)) total_cases Total_Per ;
/*	COLUMN Question  Response total_cases Total_Per;*/
	DEFINE Question/ GROUP '' center;
	DEFINE Response/ '';
	DEFINE total_cases/  format=6. "Total Cases" center;
	DEFINE Total_Per/ format=percent8.1 "% of Total" center;
RUN;

 

 

Outcomes   Total Cases % of Total
# of Newborns per Admission Single birth 209 99.1%
  Twins 2 0.9%
Gestational Age at Delivery <=28 weeks 2 1.0%
  >=29 weeks and <=36 weeks 7 3.3%
  >=37 weeks 201 95.7%
NICU Stay? No 197 92.9%
  Yes 15 7.1%
Newborn Birth Weight LBW 1500-2499 Gm (3.31 lbs-5.5 lbs) 5 2.4%
  NBW >= 2500 Gm 204 97.1%
  VLBW 500-1499 Gm (1.1 lbs-3.3 lbs) 1 0.5%

 

Besides the example above the closest I could get was this but now I have an extra row over "Total Cases" and "% of Total"

Outcomes  
Total Cases % of Total
# of Newborns per Admission Single birth 209 99.1%
  Twins 2 0.9%
Gestational Age at Delivery <=28 weeks 2 1.0%
  >=29 weeks and <=36 weeks 7 3.3%
  >=37 weeks 201 95.7%
NICU Stay? No 197 92.9%
  Yes 15 7.1%
Newborn Birth Weight LBW 1500-2499 Gm (3.31 lbs-5.5 lbs) 5 2.4%
  NBW >= 2500 Gm 204 97.1%
  VLBW 500-1499 Gm (1.1 lbs-3.3 lbs) 1 0.5%

Accepted Solutions
Solution
‎12-03-2015 02:42 PM
SAS Super FREQ
Posts: 8,820

Re: proc report spanning 2 of 4 columns in header

Hi: 

Consider the results of the following code. I think that report #2 is closer to what you want. BTW, having a relative font_size of 1 forces PDF to make a conversion from relative sizes to point sizes. You would be better off and make less work for PDF if you just specified the font in PTS.

 

cynthia

 

title;

ods pdf file='c:\temp\centerheader.pdf';

PROC REPORT DATA =sashelp.class nowd spanrows

style(report)=[rules=all]

style(header)=[cellheight=.6in font_size=1 background=lightgrey]

style(column)=[font_size=1];

title '1) PROC REPORT is putting string Outcomes on first report row';

title2 'when you blank out the header for the first 2 columns, they still take up space';

title3 'shown here as X and Y';

COLUMN ('Outcomes' age sex) height weight ;

DEFINE age/ GROUP 'X' center;

DEFINE sex/ group 'Y';

DEFINE height/ format=6. "Total Cases" center;

DEFINE weight/ format=percent8.1 "% of Total" center;

RUN;

 

PROC REPORT DATA =sashelp.class nowd spanrows

style(report)=[rules=all]

style(header)=[cellheight=.6in font_size=1 background=lightgrey]

style(column)=[font_size=1];

title '2) Move everything into column statement, then the header row will be completely empty';

title2 'and then PROC REPORT will suppress an entirely empty row';

COLUMN ('Outcomes' age sex) ("Total Cases" height) ('% of Total' weight) ;

DEFINE age/ GROUP ' ' ;

DEFINE sex/ group ' ';

DEFINE height/ format=6. " " ;

DEFINE weight/ format=percent8.1 " " ;

RUN;

ods pdf close;

View solution in original post


All Replies
Solution
‎12-03-2015 02:42 PM
SAS Super FREQ
Posts: 8,820

Re: proc report spanning 2 of 4 columns in header

Hi: 

Consider the results of the following code. I think that report #2 is closer to what you want. BTW, having a relative font_size of 1 forces PDF to make a conversion from relative sizes to point sizes. You would be better off and make less work for PDF if you just specified the font in PTS.

 

cynthia

 

title;

ods pdf file='c:\temp\centerheader.pdf';

PROC REPORT DATA =sashelp.class nowd spanrows

style(report)=[rules=all]

style(header)=[cellheight=.6in font_size=1 background=lightgrey]

style(column)=[font_size=1];

title '1) PROC REPORT is putting string Outcomes on first report row';

title2 'when you blank out the header for the first 2 columns, they still take up space';

title3 'shown here as X and Y';

COLUMN ('Outcomes' age sex) height weight ;

DEFINE age/ GROUP 'X' center;

DEFINE sex/ group 'Y';

DEFINE height/ format=6. "Total Cases" center;

DEFINE weight/ format=percent8.1 "% of Total" center;

RUN;

 

PROC REPORT DATA =sashelp.class nowd spanrows

style(report)=[rules=all]

style(header)=[cellheight=.6in font_size=1 background=lightgrey]

style(column)=[font_size=1];

title '2) Move everything into column statement, then the header row will be completely empty';

title2 'and then PROC REPORT will suppress an entirely empty row';

COLUMN ('Outcomes' age sex) ("Total Cases" height) ('% of Total' weight) ;

DEFINE age/ GROUP ' ' ;

DEFINE sex/ group ' ';

DEFINE height/ format=6. " " ;

DEFINE weight/ format=percent8.1 " " ;

RUN;

ods pdf close;

Contributor
Posts: 25

Re: proc report spanning 2 of 4 columns in header


Cynthia_sas wrote:

Hi: 

Consider the results of the following code. I think that report #2 is closer to what you want. BTW, having a relative font_size of 1 forces PDF to make a conversion from relative sizes to point sizes. You would be better off and make less work for PDF if you just specified the font in PTS.

 

cynthia

 

title;

ods pdf file='c:\temp\centerheader.pdf';

PROC REPORT DATA =sashelp.class nowd spanrows

style(report)=[rules=all]

style(header)=[cellheight=.6in font_size=1 background=lightgrey]

style(column)=[font_size=1];

title '1) PROC REPORT is putting string Outcomes on first report row';

title2 'when you blank out the header for the first 2 columns, they still take up space';

title3 'shown here as X and Y';

COLUMN ('Outcomes' age sex) height weight ;

DEFINE age/ GROUP 'X' center;

DEFINE sex/ group 'Y';

DEFINE height/ format=6. "Total Cases" center;

DEFINE weight/ format=percent8.1 "% of Total" center;

RUN;

 

PROC REPORT DATA =sashelp.class nowd spanrows

style(report)=[rules=all]

style(header)=[cellheight=.6in font_size=1 background=lightgrey]

style(column)=[font_size=1];

title '2) Move everything into column statement, then the header row will be completely empty';

title2 'and then PROC REPORT will suppress an entirely empty row';

COLUMN ('Outcomes' age sex) ("Total Cases" height) ('% of Total' weight) ;

DEFINE age/ GROUP ' ' ;

DEFINE sex/ group ' ';

DEFINE height/ format=6. " " ;

DEFINE weight/ format=percent8.1 " " ;

RUN;

ods pdf close;


#2 is the one I want. Thanks so much for the quick response and the tip about font_size.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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