BookmarkSubscribeRSS Feed
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;







  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).

  Some papers that talk about PROC REPORT are:


** 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];

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 2 in conversation