The SAS Output Delivery System and reporting techniques

Template in ods pdf

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 85
Accepted Solution

Template in ods pdf

Hi Guys,

I want to produce report something like the one attached with this. I know that we must use proc template but how can I apply the rules to have column lines only after first row.

Any help is really appreciable

picture.bmp


Accepted Solutions
Solution
‎01-15-2012 06:34 PM
SAS Super FREQ
Posts: 8,743

Re: Template in ods pdf

Hi:

  I was able to do something similar using the first 7 observations in SASHELP.CLASS. See attached screen shot. No special template was necessary. I used STYLE= overrides. You probably could package something similar into a style template, but you'd either need to set up special CSS style selectors or you'd have to set up template style elements for the different ways for the data cells to have lines; which, to me, is probably not worth the learning curve unless you are already comfortable with CSS and/or style templates.

  I think there's still some tweaking needed and I don't think that I would probably bother to use a style template since PROC REPORT seems to work pretty well. It was easier for me to make the OBSCNT variable in order to change the colors and lines (instead of the NAME values); although if you are using fixed values for your first column, you could probably use those values for your test.

  Produced with SAS 9.3 and ODS PDF and opened in Acrobat Reader X.

cynthia

ods listing close;

data class;

  set sashelp.class(obs=7);

  keep obscnt name sex charage;

  obscnt = _n_;

  if _n_ = 1 then charage = put(age,2.0);

  else charage = ' ';

run;

%let bigstyl = %str(bordertopcolor=white borderbottomcolor=white borderleftcolor=black borderrightcolor=white borderwidth=2);

options nodate nonumber;

ods pdf file='c:\temp\chgllines.pdf' notoc ;

  proc report data=class nowd

    style(header)={background=white foreground=black

                   borderwidth=2};

    column obscnt name sex charage ;

          define obscnt / order noprint;

          define name /display "Dimension Value"

           style(header)={background=white foreground=black

                          bordertopcolor=white borderbottomcolor=white

                          borderleftcolor=white borderrightcolor=black

                          borderwidth=2}

           style(column)={background=white foreground=black

                          bordertopcolor=white borderbottomcolor=white

                          borderleftcolor=white borderrightcolor=black

                          borderwidth=2};

          define sex / display "Measure From First Fact";

          define charage / display "Measure From Second Fact";

          compute charage;

            if obscnt in (1,7) then do;

              if obscnt = 1 then do;

        call define('sex','style',"style={background=cx90ee90}");

        call define('charage','style',"style={background=cx90ee90 borderbottomcolor=black}")

     end;

     else if obscnt = 7 then do;

          call define('sex','style',"style={background=cx90ee90}");

          call define('charage','style',"style={background=white &bigstyl}");

     end;

            end;

            else if obscnt in (2, 3,4,5,6) then do;

      call define('sex','style',"style={background=cyan}");

      call define('charage','style',"style={background=white &bigstyl}");

   end;

          endcomp;

run;

ods _all_ close;


change_interior.jpg

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,743

Template in ods pdf

Hi:

  You might be able to do this report with ODS LAYOUT and/or PROC REPORT. The key will be that you will have to turn off the interior table lines ... and borders for the cells on the rows underneath the Type 1 row. I see another, different issue -- getting that space underneath the table headers will be problematic because SAS expects that it will have the headers sitting on top of the data rows...not have a space underneath them.

  Actually, I wouldn't approach this as a template problem until I had experimented with PROC REPORT and style= overrides for bordertopstyle, borderbottomstyle,etc -- and I believe you need at least SAS 9.2 to accomplish or use those style attributes.

  You might want to work with Tech Support on this, since setting the individual cell borders for the different columns will need to be accomplished based on the report procedure you are using for this report (PROC REPORT, PROC TABULATE, DATA step, etc).

cynthia

Frequent Contributor
Posts: 85

Template in ods pdf

Cynthia,

Thanks for guidelines. I am working with Proc Report and I have my dataset ready with the same structure  and we are not worried about the color schemes or the space between first row and second row. My only concern is to have vertical lines limited only to first column from second row onwards... Any further comments from your side would be really helpful ....

Solution
‎01-15-2012 06:34 PM
SAS Super FREQ
Posts: 8,743

Re: Template in ods pdf

Hi:

  I was able to do something similar using the first 7 observations in SASHELP.CLASS. See attached screen shot. No special template was necessary. I used STYLE= overrides. You probably could package something similar into a style template, but you'd either need to set up special CSS style selectors or you'd have to set up template style elements for the different ways for the data cells to have lines; which, to me, is probably not worth the learning curve unless you are already comfortable with CSS and/or style templates.

  I think there's still some tweaking needed and I don't think that I would probably bother to use a style template since PROC REPORT seems to work pretty well. It was easier for me to make the OBSCNT variable in order to change the colors and lines (instead of the NAME values); although if you are using fixed values for your first column, you could probably use those values for your test.

  Produced with SAS 9.3 and ODS PDF and opened in Acrobat Reader X.

cynthia

ods listing close;

data class;

  set sashelp.class(obs=7);

  keep obscnt name sex charage;

  obscnt = _n_;

  if _n_ = 1 then charage = put(age,2.0);

  else charage = ' ';

run;

%let bigstyl = %str(bordertopcolor=white borderbottomcolor=white borderleftcolor=black borderrightcolor=white borderwidth=2);

options nodate nonumber;

ods pdf file='c:\temp\chgllines.pdf' notoc ;

  proc report data=class nowd

    style(header)={background=white foreground=black

                   borderwidth=2};

    column obscnt name sex charage ;

          define obscnt / order noprint;

          define name /display "Dimension Value"

           style(header)={background=white foreground=black

                          bordertopcolor=white borderbottomcolor=white

                          borderleftcolor=white borderrightcolor=black

                          borderwidth=2}

           style(column)={background=white foreground=black

                          bordertopcolor=white borderbottomcolor=white

                          borderleftcolor=white borderrightcolor=black

                          borderwidth=2};

          define sex / display "Measure From First Fact";

          define charage / display "Measure From Second Fact";

          compute charage;

            if obscnt in (1,7) then do;

              if obscnt = 1 then do;

        call define('sex','style',"style={background=cx90ee90}");

        call define('charage','style',"style={background=cx90ee90 borderbottomcolor=black}")

     end;

     else if obscnt = 7 then do;

          call define('sex','style',"style={background=cx90ee90}");

          call define('charage','style',"style={background=white &bigstyl}");

     end;

            end;

            else if obscnt in (2, 3,4,5,6) then do;

      call define('sex','style',"style={background=cyan}");

      call define('charage','style',"style={background=white &bigstyl}");

   end;

          endcomp;

run;

ods _all_ close;


change_interior.jpg
Frequent Contributor
Posts: 85

Re: Template in ods pdf

Superb.... thanks a ton .... I applied same logic to my code and it worked like wonders....

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 196 views
  • 0 likes
  • 2 in conversation