BookmarkSubscribeRSS Feed
gfarkas
Calcite | Level 5

Hi all,

I'm trying to figure out if there's a way to vary some of the style attributes, such as font, between different observations of the same procedure output. Specifically, I'd like to do this with PROC PRINT, and maybe PROC REPORT, outputting to HTML, PDF, and possibly RTF.

I started by playing around with the "fontlist" macro found here: http://support.sas.com/documentation/cdl/en/lrcon/62753/HTML/default/viewer.htm#n04qo8tw2712qln1mzug...

I was trying to see what all of the actual fonts looked like, rendered in those specific typefaces, rather than just listing out the font information all in the same (default) typeface. I came up with a way to do it using a macro that makes separate PROC PRINT calls, one line at a time, but that seems kind of cumbersome.

So, does anyone know if it's possible to have style elements change attributes between different observations (or sets of observations) within the same procedure output?

Thanks!

5 REPLIES 5
Tom
Super User Tom
Super User

Look at the last example on this page that does it using the TEMPLATE.

http://support.sas.com/rnd/base/new92/92odsmore.html

Cynthia_sas
SAS Super FREQ

Hi:

  Here's a simple example using PROC REPORT. All the change happens within the PROC REPORT code without using a template or a macro. Simple STYLE= overrides change the style of each row based on the value of the SEX variable on each observation.

cynthia

ods listing close;

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

ods rtf file='c:\temp\chgfont.rtf';

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

  proc report data=sashelp.class nowd;

    column name sex age height weight;

          define name /display;

          define sex / display;

          define age / display;

          define height / display;

          define weight / display;

          compute sex;

            if sex = 'F' then do;

               call define(_row_,'style',"style={font_face='Helvetica' fontsize=18pt}");

            end;

      else do;

               call define(_row_,'style',"style={font_face='Courier New' fontsize=20pt}");

            end;

          endcomp;

run;

ods _all_ close;

Ksharp
Super User

Cynthia .

Another way is to use Traffic Light Skill.  Just like change the color of font.

Firstly, use proc format make a format, then use it in proc print or proc report.

proc format;
value $ fmt
 'F'='20pt'
 'M'='10pt';
run;

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

  proc report data=sashelp.class nowd;
    column name sex age height weight;
          define name /display;
          define sex/display style={fontsize=$fmt.};
run;

ods html close;


Ksharp

gfarkas
Calcite | Level 5

Hi Cynthia,

Thanks for the helpful response! That is basically what I want, although not exactly. If you look at the "fontlist" macro in the link from my original post, I am trying to replace the PROC PRINT call at the end of the macro. What I would like to replace it with is basically something like either of the following, although neither of the below PROC REPORT calls do exactly what I'm looking for as-is.

proc report data=fonts2 center spanrows nowd style(report) = {font_size = 14pt} ;

column font fstyle fweight type ;

define font / display ;

define fstyle / display ;

define fweight / display ;

define type / display ;

compute font ;

    call define(_row_,'style/merge',"style={font_face='"||font||"'}");

    endcomp;

compute fstyle ;

    call define(_row_,'style/merge',"style={font_style='"||fstyle||"'}");

    endcomp;

compute fweight ;

    call define(_row_,'style/merge',"style={font_weight='"||fweight||"'}");

    endcomp;

run; quit;

proc report data=fonts2 center spanrows nowd style(report) = {font_size = 14pt} ;

column font fstyle fweight type ;

define font / display ;

define fstyle / display ;

define fweight / display ;

define type / display ;

compute font ;

    call define(_row_,'style/merge',"style={font_face='"||font||"' font_style='"||fstyle||"' font_weight='"||fweight||"'}");

    endcomp;

run; quit;

In both cases, the font face is rendered correctly, but the font style and font weight do not render at all. In addition, I get a whole bunch of errors like the following:

ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, !, @, DYNAMIC,

              EXPRESSION, ITALIC, RESOLVE, ROMAN, SLANT, SYMGET, _UNDEFINE_, _UNDEF_, _UND_, |.

ERROR 76-322: Syntax error, statement will be ignored.

I've revised some of the values of FSTYLE and FWEIGHT so that they are all valid values (eg, ITALIC, ROMAN, etc), so that's not it. In case you're interested, I'm attaching the output from the first PROC REPORT call.

gfarkas
Calcite | Level 5

Never mind. I had extra single quotes around the font style and font weight. It works now. Thanks again!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 1306 views
  • 0 likes
  • 4 in conversation