Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!

PROC REPORT losing ods htmlblue style with call define

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

PROC REPORT losing ods htmlblue style with call define

Hi all,

 

I'm on SAS 9.4.

 

With the below code I'm attempting to create a "Total" line in my report. What I'm finding is that the methodology I'm employing to create the "Total" cell is overwriting the ods style htmlblue and making it "plain". Any suggestions for fixing this?

 

ods escapechar="^";

options nodate label;

ods _all_ close;

ods pdf file = "\\hne_crms\hsra\testing.pdf"

style = htmlblue;

 

PROC REPORT DATA=WORK.STEP3 SPANROWS style(summary)=Header;

BY 'Group Nbr'n;

COLUMN EmployerInfo 'Claims ID'n DOS 'Billed Amt'n Adjustment 'Amount Pd'n;

DEFINE EMPLOYERINFO / group ORDER;

DEFINE 'Claims ID'n / group ORDER "Claims ID";

DEFINE DOS / group ORDER;

DEFINE 'Billed Amt'n / "Billed Amt" format=dollar16.2;

DEFINE Adjustment / "Adjustment" format=dollar16.2;

DEFINE 'Amount Pd'n / ANALYSIS SUM "Amount Pd" format=dollar16.2;

compute after;

if _break_='_RBREAK_' then

call define('DOS', 'style', 'style=[pretext="Total"]');

endcomp;

RBREAK AFTER / SUMMARIZE;

RUN;

ods pdf close;


Accepted Solutions
Solution
‎06-28-2018 11:14 AM
SAS Super FREQ
Posts: 9,436

Re: PROC REPORT losing ods htmlblue style with call define

[ Edited ]

Hi, Why do you have "GROUP ORDER" for all your variables? PROC REPORT will only "accept" one usage and the last usage that is listed "wins" So your GROUP is being ignored and reset to ORDER for each of these variables.

Is DOS a numeric or character variable. I generally find I need to use PRETEXT only on those occasions when my variable is numeric.

You could always try
'style=Header[pretext="Total"]'

for the value of the 3rd argument to Call Define.

The reason it happens is that the style is applied like this:
1) STYLE= option in your ODS PDF statement
2) STYLE(SUMMARY) option in your PROC REPORT statement
3) CALL DEFINE STYLE override in your COMPUTE block.

Think of PROC REPORT as making a little pile of all the various STYLE options from the original style definition and then you're going thru and making overrides. It's better to be specific that in the ONE cell you're touching with your CALL DEFINE, you want both a style of HEADER and PRETEXT.

 

  One way to get around needing a call define at all is to make a character version of your numeric variable, as I have done in the #2 example below. I used SASHELP.CLASS with AGE as the first column. In the first example, I use PRETEXT and in the second example, I make a character version of AGE that is big enough to hold the string 'Total' and with the second example, I don't need a CALL DEFINE statement at all.

 

proc sort data=sashelp.class out=class;
by sex age;
run;

ods escapechar="^";
options nodate label;
ods _all_ close;
ods pdf file = "c:\temp\summary_testing.pdf" style = htmlblue;

PROC REPORT DATA=class SPANROWS 
     style(summary)=Header;
BY sex;
COLUMN age name height weight;
DEFINE age /  ORDER;
DEFINE name /  ORDER;
DEFINE height / "Adjustment" sum format=dollar16.2;
DEFINE weight / ANALYSIS SUM "Amount Pd" format=dollar16.2;
compute after;
if _break_='_RBREAK_' then
  call define('AGE', 'style', 'style=Header[pretext="Total"]');
endcomp;
RBREAK AFTER / SUMMARIZE;
RUN;

ods pdf close;

ods pdf file = "c:\temp\summary_testing2.pdf" style = htmlblue;
data tempclass;
  length charage $5;
  set class; by sex age;
  charage = put(age,2.0);
run;

PROC REPORT DATA=tempclass SPANROWS 
     style(summary)=Header;
BY sex;
COLUMN age charage name height weight;
define age / order noprint;
DEFINE charage /  ORDER  'Age';
DEFINE name /  ORDER;
DEFINE height / "Adjustment" sum format=dollar16.2;
DEFINE weight / SUM "Amount Pd" format=dollar16.2;
compute after;
  charage='Total';
endcomp;
RBREAK AFTER / SUMMARIZE;
RUN;

ods pdf close;

  I like to keep my original variable (in this case, AGE) on the column statement, but as a NOPRINT, so I can use it to double check my values if I need to.

Cynthia

View solution in original post


All Replies
Solution
‎06-28-2018 11:14 AM
SAS Super FREQ
Posts: 9,436

Re: PROC REPORT losing ods htmlblue style with call define

[ Edited ]

Hi, Why do you have "GROUP ORDER" for all your variables? PROC REPORT will only "accept" one usage and the last usage that is listed "wins" So your GROUP is being ignored and reset to ORDER for each of these variables.

Is DOS a numeric or character variable. I generally find I need to use PRETEXT only on those occasions when my variable is numeric.

You could always try
'style=Header[pretext="Total"]'

for the value of the 3rd argument to Call Define.

The reason it happens is that the style is applied like this:
1) STYLE= option in your ODS PDF statement
2) STYLE(SUMMARY) option in your PROC REPORT statement
3) CALL DEFINE STYLE override in your COMPUTE block.

Think of PROC REPORT as making a little pile of all the various STYLE options from the original style definition and then you're going thru and making overrides. It's better to be specific that in the ONE cell you're touching with your CALL DEFINE, you want both a style of HEADER and PRETEXT.

 

  One way to get around needing a call define at all is to make a character version of your numeric variable, as I have done in the #2 example below. I used SASHELP.CLASS with AGE as the first column. In the first example, I use PRETEXT and in the second example, I make a character version of AGE that is big enough to hold the string 'Total' and with the second example, I don't need a CALL DEFINE statement at all.

 

proc sort data=sashelp.class out=class;
by sex age;
run;

ods escapechar="^";
options nodate label;
ods _all_ close;
ods pdf file = "c:\temp\summary_testing.pdf" style = htmlblue;

PROC REPORT DATA=class SPANROWS 
     style(summary)=Header;
BY sex;
COLUMN age name height weight;
DEFINE age /  ORDER;
DEFINE name /  ORDER;
DEFINE height / "Adjustment" sum format=dollar16.2;
DEFINE weight / ANALYSIS SUM "Amount Pd" format=dollar16.2;
compute after;
if _break_='_RBREAK_' then
  call define('AGE', 'style', 'style=Header[pretext="Total"]');
endcomp;
RBREAK AFTER / SUMMARIZE;
RUN;

ods pdf close;

ods pdf file = "c:\temp\summary_testing2.pdf" style = htmlblue;
data tempclass;
  length charage $5;
  set class; by sex age;
  charage = put(age,2.0);
run;

PROC REPORT DATA=tempclass SPANROWS 
     style(summary)=Header;
BY sex;
COLUMN age charage name height weight;
define age / order noprint;
DEFINE charage /  ORDER  'Age';
DEFINE name /  ORDER;
DEFINE height / "Adjustment" sum format=dollar16.2;
DEFINE weight / SUM "Amount Pd" format=dollar16.2;
compute after;
  charage='Total';
endcomp;
RBREAK AFTER / SUMMARIZE;
RUN;

ods pdf close;

  I like to keep my original variable (in this case, AGE) on the column statement, but as a NOPRINT, so I can use it to double check my values if I need to.

Cynthia

Occasional Contributor
Posts: 5

Re: PROC REPORT losing ods htmlblue style with call define

Posted in reply to Cynthia_sas

Hi Cynthia,

 

Thanks so much for your help.

 

I was using GROUP ORDER because I was unaware of the parameter you described. I removed group. Your suggested edit of Style=Header in the call define code worked - thank you!

 

Here is what my ODS PDF output looks like now:

 

Capture.GIF

 

Two questions for you:

 

1) How do I get Billed Amt and Adjustment to not sum? I would prefer to only SUM the final column, Amt Pd.

2) In the Total row, could I merge all of those cells that are not SUMmed? So for example, have "Total" sit under EmployerInfo with no vertical lines until the $376.40 sum.

 

Thank you,

Ryan

 

SAS Super FREQ
Posts: 9,436

Re: PROC REPORT losing ods htmlblue style with call define

Hi:
If you want Billed Amt and Adjustment not to sum, then change their usage from ANALYSIS SUM or SUM to DISPLAY. Report items/variables that have a usage of DISPLAY are NOT summarized on a break.

Unfortunately, you could make TOTAL appear in the EMPLOYER_INFO cell on the summary line by changing your COMPUTE AFTER to be
EMPLOYER_INFO='Total';
instead of assigning the string to DOS using PRETEXT. But you can't merge the cells the way you want. You can "disappear" the divider lines by changing to a style like JOURNAL, but PROC REPORT doesn't merge cells the way you can do with Excel.
Cynthia
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 163 views
  • 1 like
  • 2 in conversation