BookmarkSubscribeRSS Feed
mpajoh
Fluorite | Level 6

How can the following be done using proc report?

-------------------------------------------------------------

proc print data=a split='\' noobs label (report)=[rules=none];

    title2 j=c c=red "#byval1 - " c=blue h=0.8 "#byval2";

    by project category;

    var x y z / style=[just=c vjust=c leftmargin=2mm rightmargin=2mm ];

    var a b  / style=[ vjust=c leftmargin=2mm rightmargin=2mm ];

    var iunits / style=[just=c vjust=c leftmargin=2mm rightmargin=2mm ];

    var est extes /style =[ vjust=c leftmargin=2mm rightmargin=2mm ];

    sum estimate / style(grandtotal)=[background=red foreground=white]

    style(total)=[background=black foreground=white];

sumby category;

run;

-------------------------------------------------------------

Thanks;

Masoud

1 REPLY 1
Cynthia_sas
Diamond | Level 26

Hi:

  You will have to read about PROC REPORT for a full example. Basically, you will have a COLUMN statement that will list your items, from left to right. Then instead of multiple VAR statements, you will need a DEFINE statement for every item that you want to change, style-wise. (Also, you should consider using the correct syntax for the style override. For PROC PRINT, it is STYLE(DATA)={...} but for PROC REPORT, it will be
STYLE(COLUMN)={...}, as shown below.

  PROC REPORT does totals differently than PROC PRINT does. You may find that you need both a BREAK and/or an RBREAK statement in order to get both subtotals and grand totals at the end of the report. You may or may not need BY group processing -- a BREAK statement does SUBTOTALS and an RBREAK statement does a grand total. You can use a STYLE= option for these on the BREAK or RBREAK statement.

   You did not say what your destination of interest was. However, a value of .8 for H (which corresponds to font size) seems rather odd. It is better to specify units of measure for font size. A simple point size specification would be better: H=12pt or H=6pt or H=8pt -- any of those would work for RTF, PDF or HTML. Also, valid values for VJUST (or VERTICALALIGN) are T (top), M (middle) or B (bottom).

http://support.sas.com/documentation/cdl/en/odsug/61723/HTML/default/viewer.htm#a002972093.htm

  Some papers that talk about PROC REPORT are:

http://www.pharmasug.org/proceedings/2012/TF/PharmaSUG-2012-TF20-SAS.pdf

http://www2.sas.com/proceedings/sugi31/235-31.pdf

http://www2.sas.com/proceedings/sugi30/244-30.pdf

http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf

cynthia


** untested code -- not at computer with SAS;

proc report data=a split='\' nowd
            style (report)=[rules=none];
    by project category;
    title2 j=c c=red "#byval1 - " c=blue h=0.8 "#byval2";
  COLUMN x y z a b iunits est estes estimate;
  define x / display style(column)=[just=c vjust=m leftmargin=2mm rightmargin=2mm ];;
  define y / display  style(column)=[just=c vjust=m leftmargin=2mm rightmargin=2mm ];
  define z / display  style(column)=[just=c vjust=m leftmargin=2mm rightmargin=2mm ];

... more DEFINE statements ....

  rbreak after / summarize style=[background=red foreground=white];
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1305 views
  • 0 likes
  • 2 in conversation