The SAS Output Delivery System and reporting techniques

Can a format use unicode characters and have different font sizes?

Reply
Super Contributor
Posts: 333

Can a format use unicode characters and have different font sizes?

We would like to use the up and down arrows in unicode (dont have the codes handy right now) but for them to be big enough to see they must be 14pt font while the rest of the text is 10pt.

Is there a way using a format or compute block in proc report to get this desired results?

What we are trying to mimic ->

4-20-2015 9-14-00 AM.gif

What we have so far -> (colors are fixable ... so we are not worried about that)

4-20-2015 9-16-31 AM.gif

Code we are using: (code is a different contract version so as not to disclose any results ... the difference is there are more plans so more columns than the screen shots)

proc report data=for_tbl5 nowd

         style(header)={background=CX0000FF font_face="Arial" color=white}

         style(column)={font_face="Arial"}

         ;

      by notsorted standard ;

      column ("Section" (section)) ("Question" (question))

         ("ECBH" (ECBH ECBHM ))

         ("Smoky Mountain Center" (Smoky_Mountain_Center Smoky_Mountain_CenterM))

       ("Sandhills" (Sandhills SandhillsM))

         ;

      define section / group order=data "" style(column)={cellwidth=1.3 in just=left} ;

      define question / order=data "" style(column)={cellwidth=3 in

                                                         just=Left

                                                         };

      define ECBH / "" style(column)={cellwidth=.9 in just=center vjust=center} ;

      define ECBHM / "" style(column)={cellwidth=.3 in

                                                      just=center

                                                      vjust=center

                                                      font_face="Wingdings 3"

                                                      font_size=12 pt

                                                      } ;

      define Smoky_Mountain_Center / "" style(column)={cellwidth=.9 in just=center vjust=center } ;

      define Smoky_Mountain_Centerm / "" style(column)={cellwidth=.3 in

                                             just=center

                                             vjust=center

                                             font_face="Wingdings 3"

                                             font_size=12 pt

                                             } ;  

      define Sandhills / "" style(column)={cellwidth=.9 in just=center vjust=center } ;

      define Sandhillsm / "" style(column)={cellwidth=.3 in

                                             just=center

                                             vjust=center

                                             font_face="Wingdings 3"

                                             font_size=12 pt

                                             } ; 

      compute ECBHM ;

         if _c3_ = "Met" then call define("_c4_", "Style", "Style={background=&green}") ;

         if _c3_ = "Met" then call define("_c3_", "Style", "Style={background=&green}") ;

         if _c3_ = "Partially Met" then call define("_c4_", "Style", "Style={background=&yellow}") ;

         if _c3_ = "Partially Met" then call define("_c3_", "Style", "Style={background=&yellow}") ;

         if _c3_ = "Not Met" then call define("_c4_", "Style", "Style={background=&red}") ;

         if _c3_ = "Not Met" then call define("_c3_", "Style", "Style={background=&red}") ;

         if _c3_ = "Not Evaluated" then call define("_c4_", "Style", "Style={background=&blue}") ;

         if _c3_ = "Not Evaluated" then call define("_c3_", "Style", "Style={background=&blue}") ;

         if _c3_ = "Not Applicable" then call define("_c4_", "Style", "Style={background=&purple}") ;

         if _c3_ = "Not Applicable" then call define("_c3_", "Style", "Style={background=&purple}") ;

      endcomp ;

      compute Smoky_Mountain_Centerm ;

         if _c5_ = "Met" then call define("_c6_", "Style", "Style={background=&green}") ;

         if _c5_ = "Met" then call define("_c5_", "Style", "Style={background=&green}") ;

         if _c5_ = "Partially Met" then call define("_c6_", "Style", "Style={background=&yellow}") ;

         if _c5_ = "Partially Met" then call define("_c5_", "Style", "Style={background=&yellow}") ;

         if _c5_ = "Not Met" then call define("_c6_", "Style", "Style={background=&red}") ;

         if _c5_ = "Not Met" then call define("_c5_", "Style", "Style={background=&red}") ;

         if _c5_ = "Not Evaluated" then call define("_c6_", "Style", "Style={background=&blue}") ;

         if _c5_ = "Not Evaluated" then call define("_c5_", "Style", "Style={background=&blue}") ;

         if _c5_ = "Not Applicable" then call define("_c6_", "Style", "Style={background=&purple}") ;

         if _c5_ = "Not Applicable" then call define("_c5_", "Style", "Style={background=&purple}") ;

      endcomp ;

      compute Sandhillsm ;

         if _c7_ = "Met" then call define("_c7_", "Style", "Style={background=&green}") ;

         if _c7_ = "Met" then call define("_c8_", "Style", "Style={background=&green}") ;

         if _c7_ = "Partially Met" then call define("_c7_", "Style", "Style={background=&yellow}") ;

         if _c7_ = "Partially Met" then call define("_c8_", "Style", "Style={background=&yellow}") ;

         if _c7_ = "Not Met" then call define("_c7_", "Style", "Style={background=&red}") ;

         if _c7_ = "Not Met" then call define("_c8_", "Style", "Style={background=&red}") ;

         if _c7_ = "Not Evaluated" then call define("_c7_", "Style", "Style={background=&blue}") ;

         if _c7_ = "Not Evaluated" then call define("_c8_", "Style", "Style={background=&blue}") ;

         if _c7_ = "Not Applicable" then call define("_c7_", "Style", "Style={background=&purple}") ;

         if _c7_ = "Not Applicable" then call define("_c8_", "Style", "Style={background=&purple}") ;

      endcomp ;

   run ;

Thanks!

Ericreport

Super Contributor
Posts: 333

Re: Can a format use unicode characters and have different font sizes?

I made sure the check box was marked to show this as a question ... but it shows a discussion. Interesting.

Eric

SAS Super FREQ
Posts: 8,642

Re: Can a format use unicode characters and have different font sizes?

Hi:

  I'm curious. Why are you using absolute column numbers? I don't see any ACROSS usage in your report. Can you dummy up some data and show ALL of your code? Also, are you referring to a "format" in general as the "format in a cell" or are you referring to a user-defined format (which I don't see referenced in your code.

cynthia

SAS Super FREQ
Posts: 8,642

Re: Can a format use unicode characters and have different font sizes?

Here's some test code using Arial Unicode MS for arrows.

add_unicode_for_name.png

proc format;

   value $namef 'Alfred' = 'Alfred ^{style[font_size=16pt]^{unicode 21A1}}'

                'John' = 'John ^{style[font_size=16pt]^{unicode 2195}}'

                'Ronald' = 'Robert ^{style[font_size=16pt]^{unicode 27B9}}'

                'Barbara' = 'Barbara ^{style[font_size=16pt]^{unicode 27B7}}';

run;

data class;

  length newname $150;

  set sashelp.class;

  newname = put(name,$namef.);

run;

ods escapechar='^';

ods html file='c:\temp\showunicode.html';

proc report data=class nowd

     style(report)={font_face='Arial Unicode MS'}

     style(header)={font_face='Arial Unicode MS'}

     style(column)={font_face='Arial Unicode MS'};

  column age name newname sex height weight;

  define age / order;

  define name / display noprint;

  define newname /display;

  define sex / display;

  define height / display;

  define weight / display;

  compute newname;

    if name = 'Alfred' then do;

       call define(_col_,'style','style={font_face="Arial Unicode MS" background=lightblue}');

    end;

    else if name = 'Barbara' then do;

       call define(_col_,'style','style={font_face="Arial Unicode MS" background=lightpurple}');

    end;

    else if name = 'John' then do;

       call define(_col_,'style','style={font_face="Arial Unicode MS" background=lightgreen}');

    end;

    else if name = 'Ronald' then do;

       call define(_col_,'style','style={font_face="Arial Unicode MS" background=lightred}');

    end;

  endcomp;

run;

ods html close;

Super Contributor
Posts: 333

Re: Can a format use unicode characters and have different font sizes?

Thanks Cynthia ... we didnt understand exactly how to use the format when we started to use this report so we began with a hard coding of the compute blocks.

I think this code is pretty close to what we need and gives us the syntax that we were missing.

Thanks for the help!

Eric

Contributor
Posts: 21

Re: Can a format use unicode characters and have different font sizes?

This output reminds me of a problem I've been seeing. The report rows containing Unicode chars are taller than the other rows. I've been trying to figure out a way to make those rows the same height as the others. Can I set the font size for the Unicode character? Seems especially bad in PDF output.

Grand Advisor
Posts: 9,699

Re: Can a format use unicode characters and have different font sizes?

An old-school solution for the text, depending on how married you are to Unicode and the current font you may use, one option might be to select a font that has an up/down arrow in the high order ASCII values from 128 to 255.

Post a Question
Discussion Stats
  • 6 replies
  • 650 views
  • 2 likes
  • 4 in conversation