Data visualization with SAS programming

ODS Proc Report - Trouble with conditional formatting with compute statement - Sizing of Ggchart/Report

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

ODS Proc Report - Trouble with conditional formatting with compute statement - Sizing of Ggchart/Report

Using SAS 9.2

I have been trying to get only some columns to conditionally format.  Well, I am sucessfull in getting all columns to format, now I only want Female columns to be highlighted.  No matter what I try, both male and females are highlighted.  Here is my latest attempt: (Arg!  why do I always have trouble with cut and paste!)   I have attached my code and report sample!  Notice that I conditionally format cells using a a couple of proc formats!  (Plus I have changed the names of variables, etc for confidentiality)

I have a proc gchart above the proc report.  The dimensions are on the gchart are as small as far as I need, but I need to shrink the width and height of the proc report.  I think I understand how to control size parameters in proc gchart, but not really with the proc report.  I need to fit as much data as possible on the page.  I have 400+ gchart/proc reports to create! Suggestions on shrinking the font and/or size of the proc report would be greatly appreciated.

Plus, when the gchart and proc report are placed on the .rtf page, there are two lines in between them.    How can I place the proc report higher on the page?   I need to add a title to the top of the page, so I need another couple lines for space.

Can I remove the header cells (the entire row)  for gender_ in the across variable?  I don't need it.

Need your opinion, can I fit more on a .pdf than a .rtf?  I don't care what ODS output I use, just as long as I can print it and it's legible.

Linda 

Attachment
Attachment

Accepted Solutions
Solution
‎04-30-2012 09:36 PM
SAS Super FREQ
Posts: 8,643

Re: ODS Proc Report - Trouble with conditional formatting with compute statement - Sizing of Ggchart/Report

Hi:

  I answered this in your other posting. Or rather, I made some suggestions. Usually when you get "unitialized" messages, it is because you are using the wrong reference. For example, run the code below and examine the output from each step for a better understanding about how to reference absolute columns.

cynthia

ods listing close;

                    

ods html file='c:\temp\across1.html' style=sasweb;

** Default;

proc report data=sashelp.class nowd;

title '1) default appearance';

column sex age,height;

define sex / group;

define age / across;

define height / mean;

run;

ods html close;

                     

** User-defined format for all HEIGHT values;

proc format;

  value ah low-55.999 = 'pink'

           56-63.999 = 'cyan'

           64-69.999 = 'yellow'

           70-high = 'verylightblue'

           other = 'cxdddddd';

run;

                   

ods html file='c:\temp\across2.html' style=sasweb;

proc report data=sashelp.class nowd;

title '2) With User-Defined Format';

column sex age,height;

define sex / group;

define age / across ;

define height / mean style(column)={background=ah.};

run;

ods html close;

   

                        

** With CALL DEFINE for ALL columns;

ods html file='c:\temp\across3.html' style=sasweb;

proc report data=sashelp.class nowd;

title '3) With CALL DEFINE Format for HEIGHT';

title2 'height will have format, but weight will not';

column sex age,(height weight);

define sex / group;

define age / across ;

define height / mean;

define weight / mean;

compute height;

  call define(_col_,'style','style={background=ah.}');

endcomp;

run;

ods html close;

                   

** With CALL DEFINE on only some across items;

ods html file='c:\temp\across4.html' style=sasweb;

proc report data=sashelp.class nowd;

title '4) With CALL DEFINE Format on _C#_';

column sex age,(height weight);

define sex / group;

define age / across ;

define height / mean;

define weight / mean;

compute height;

  /* _c2_ is height/age=11  _c3_ is weight/age=11*/

  call define('_c2_','style','style={background=ah.}');

           

  /* _c4_ is height/age=12 */

  call define('_c4_','style','style={background=ah.}');

   

  /* _c6_ is height/age=13 */

  call define('_c6_','style','style={background=ah.}');

         

  /* do NOT apply format to height for ages 14 and 15 */

  /* age=14 _c8_=height, _c9_=weight */

  /* age=15 _c10_=height, _c11_=weight */

         

  /* _c12_ is height/age=16 */

  call define('_c12_','style','style={background=ah.}');

endcomp;

run;

ods html close;

View solution in original post


All Replies
Super User
Super User
Posts: 5,970

Re: ODS Proc Report - Trouble with conditional formatting with compute statement - Sizing of Ggchart/Report

Since you are using gender as an ACROSS variable if you want to reference the MALE and FEMALE columns in the report you need to reference them by column number and not by variable name.  See if you can get it to work that way.

Otherwise perhaps you can just transform the data so that the male and female number as stored in separate variables.

Contributor
Posts: 31

Re: ODS Proc Report - Trouble with conditional formatting with compute statement - Sizing of Ggchart/Report

I have thought about creating separate variables for male and female.  However, I don't want to LOSE the across functionality.   I need to show the ratings1-5, SD and count by each gender.

How would I reference by column number?  Is that _col_=4 for gender?  I have coded SAS for many years, but never proc report.  So, this all seems so strange to me! 

Contributor
Posts: 31

Re: ODS Proc Report - Trouble with conditional formatting with compute statement - Sizing of Ggchart/Report

This is from the proc report.  I keeping getting an error with the compute OR at least I think it's coming from compute section.  Why can't it find gender_?  It is in the input file?

 

NOTE: Variable gender_ is uninitialized.

NOTE: There were 40 observations read from the data set

WORK.GENDER_FINAL_REPORT.

NOTE: PROCEDURE REPORT used (Total process time):

real time 0.10 seconds

cpu time 0.09 seconds


Solution
‎04-30-2012 09:36 PM
SAS Super FREQ
Posts: 8,643

Re: ODS Proc Report - Trouble with conditional formatting with compute statement - Sizing of Ggchart/Report

Hi:

  I answered this in your other posting. Or rather, I made some suggestions. Usually when you get "unitialized" messages, it is because you are using the wrong reference. For example, run the code below and examine the output from each step for a better understanding about how to reference absolute columns.

cynthia

ods listing close;

                    

ods html file='c:\temp\across1.html' style=sasweb;

** Default;

proc report data=sashelp.class nowd;

title '1) default appearance';

column sex age,height;

define sex / group;

define age / across;

define height / mean;

run;

ods html close;

                     

** User-defined format for all HEIGHT values;

proc format;

  value ah low-55.999 = 'pink'

           56-63.999 = 'cyan'

           64-69.999 = 'yellow'

           70-high = 'verylightblue'

           other = 'cxdddddd';

run;

                   

ods html file='c:\temp\across2.html' style=sasweb;

proc report data=sashelp.class nowd;

title '2) With User-Defined Format';

column sex age,height;

define sex / group;

define age / across ;

define height / mean style(column)={background=ah.};

run;

ods html close;

   

                        

** With CALL DEFINE for ALL columns;

ods html file='c:\temp\across3.html' style=sasweb;

proc report data=sashelp.class nowd;

title '3) With CALL DEFINE Format for HEIGHT';

title2 'height will have format, but weight will not';

column sex age,(height weight);

define sex / group;

define age / across ;

define height / mean;

define weight / mean;

compute height;

  call define(_col_,'style','style={background=ah.}');

endcomp;

run;

ods html close;

                   

** With CALL DEFINE on only some across items;

ods html file='c:\temp\across4.html' style=sasweb;

proc report data=sashelp.class nowd;

title '4) With CALL DEFINE Format on _C#_';

column sex age,(height weight);

define sex / group;

define age / across ;

define height / mean;

define weight / mean;

compute height;

  /* _c2_ is height/age=11  _c3_ is weight/age=11*/

  call define('_c2_','style','style={background=ah.}');

           

  /* _c4_ is height/age=12 */

  call define('_c4_','style','style={background=ah.}');

   

  /* _c6_ is height/age=13 */

  call define('_c6_','style','style={background=ah.}');

         

  /* do NOT apply format to height for ages 14 and 15 */

  /* age=14 _c8_=height, _c9_=weight */

  /* age=15 _c10_=height, _c11_=weight */

         

  /* _c12_ is height/age=16 */

  call define('_c12_','style','style={background=ah.}');

endcomp;

run;

ods html close;

Contributor
Posts: 31

Re: ODS Proc Report - Trouble with conditional formatting with compute statement - Sizing of Ggchart/Report

Now I get it!!!!  You actually count the columns in the report!  So simple, yet so elusive!  The conditional cell highlighting now works!!!!!  Terrific!

I am doing the work of a third party vendor.  I have put my neck on the line stating that I can create 400+ reports/barchart combos in SAS!  I am very close to finalizing the first template, which is the hardest part.  You have helped tremendously!  I love to make SAS a favorite analyst tool for everyone, not just me!

THANK YOU! THANK YOU!  THANK YOU!!!!!!!!!

Linda

Post a Question
Discussion Stats
  • 5 replies
  • 394 views
  • 0 likes
  • 3 in conversation