BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Cristina_inet
Fluorite | Level 6

Hello everyone,
we are generating some pdf reports, in them there are tables generated with proc report.
We are asked if it is possible for the header columns to appear as follows:

 

Cristina_inet_0-1691756799432.png

The cells above should appear blank.

 

Right now we are displaying it as follows:

Cristina_inet_1-1691756894519.png

The code:

proc report data=VER
      STYLE(header)=[ backgroundcolor=#8DB4E2 ]
      style(header)={verticalalign=middle};

  columns ('Tipo de vía' (TIPO_VIA_4F))  ("&anyo2."(muertos&anyo2.)) ("&anyo3."(muertos&anyo3.))  ('Diferencias'(FDIF_&anyo3._&anyo2. ));

  define TIPO_VIA_4F          / order order=data '' STYLE(header)=[backgroundcolor=white] STYLE(column)=[Color=darkblue] display left;
  define muertos&anyo2.       / order order=data 'Nº' display right;
  define muertos&anyo3.       / order order=data 'Nº' display right;
  define FDIF_&anyo3._&anyo2. / order order=data "&anyo3.-&anyo2." display right;

  compute  muertos&anyo2;       if TIPO_VIA_4F = 'TOTAL' then   call define (_col_,"style","STYLE=[fontweight=bold]"); Endcomp;
  compute  TIPO_VIA_4F;         if TIPO_VIA_4F = 'TOTAL' then   call define (_col_,"style","STYLE=[fontweight=bold]"); Endcomp;
  compute  muertos&anyo3;       if TIPO_VIA_4F = 'TOTAL' then   call define (_col_,"style","STYLE=[fontweight=bold]"); Endcomp;
  compute  FDIF_&anyo3._&anyo2; if TIPO_VIA_4F = 'TOTAL' then   call define (_col_,"style","STYLE=[fontweight=bold]"); Endcomp;
run;

Thank you very much for the help.
Greetings.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
proc format;
value $ fmt
'09'x='white'
other='#8DB4E2 ';
run;

proc report data=sashelp.class
      STYLE(header)=[ backgroundcolor=$fmt. ] nowd;
column ("09"x  name) ('xxxx' height) ("yyyy" weight);
define name/display ;
run;

Ksharp_1-1691833100564.png

 

View solution in original post

6 REPLIES 6
data_null__
Jade | Level 19

@Cristina_inet wrote:

Hello everyone,
we are generating some pdf reports, in them there are tables generated with proc report.
We are asked if it is possible for the header columns to appear as follows:

 

Cristina_inet_0-1691756799432.png

The cells above should appear blank.

 

Right now we are displaying it as follows:

Cristina_inet_1-1691756894519.png

The code:

proc report data=VER
      STYLE(header)=[ backgroundcolor=#8DB4E2 ]
      style(header)={verticalalign=middle};

  columns ('Tipo de vía' (TIPO_VIA_4F))  ("&anyo2."(muertos&anyo2.)) ("&anyo3."(muertos&anyo3.))  ('Diferencias'(FDIF_&anyo3._&anyo2. ));

  define TIPO_VIA_4F          / order order=data '' STYLE(header)=[backgroundcolor=white] STYLE(column)=[Color=darkblue] display left;
  define muertos&anyo2.       / order order=data 'Nº' display right;
  define muertos&anyo3.       / order order=data 'Nº' display right;
  define FDIF_&anyo3._&anyo2. / order order=data "&anyo3.-&anyo2." display right;

  compute  muertos&anyo2;       if TIPO_VIA_4F = 'TOTAL' then   call define (_col_,"style","STYLE=[fontweight=bold]"); Endcomp;
  compute  TIPO_VIA_4F;         if TIPO_VIA_4F = 'TOTAL' then   call define (_col_,"style","STYLE=[fontweight=bold]"); Endcomp;
  compute  muertos&anyo3;       if TIPO_VIA_4F = 'TOTAL' then   call define (_col_,"style","STYLE=[fontweight=bold]"); Endcomp;
  compute  FDIF_&anyo3._&anyo2; if TIPO_VIA_4F = 'TOTAL' then   call define (_col_,"style","STYLE=[fontweight=bold]"); Endcomp;
run;

Thank you very much for the help.
Greetings.


*remove header text from column statement;
columns (TIPO_VIA_4F)  ("&anyo2."(muertos&anyo2.)) ("&anyo3."(muertos&anyo3.))  ('Diferencias'(FDIF_&anyo3._&anyo2. ));
*Add the text here;
define TIPO_VIA_4F          / order order=data 'Tipo de vía'  STYLE(header)=[backgroundcolor=white] STYLE(column)=[Color=darkblue] display left;Th

This is untested.

Ksharp
Super User
proc format;
value $ fmt
'09'x='white'
other='#8DB4E2 ';
run;

proc report data=sashelp.class
      STYLE(header)=[ backgroundcolor=$fmt. ] nowd;
column ("09"x  name) ('xxxx' height) ("yyyy" weight);
define name/display ;
run;

Ksharp_1-1691833100564.png

 

Tom
Super User Tom
Super User

That is a cool trick.  But it would be better to use something like 'A0'x instead of a TAB.  Then it won't mess up the normal listing output column alignments.

Tom_0-1691855644871.pngTom_1-1691855672114.png

 

 

 

Ksharp
Super User

Tom,

But if I use '0A'x ,I got this under unicode sas or Chinese sas. (HTML destination)

 

Ksharp_0-1691917882740.png

 

Tom
Super User Tom
Super User

Not sure why you used a LINEFEED.  Not sure why Chinese encoding would display a character for either a linefeed or a non-breaking space.  Are you use double byte character set?  If so you probably need to two byte character.

 

Why not just use a normal space then?

Ksharp
Super User

Tom,
Opps. It is typo.
I am from China.
So I have to use multi byte character set,like Chines or UTF-8 .

Ksharp_0-1692012293698.png

Ksharp_1-1692012305568.png

Ksharp_2-1692012344478.png

 

 

 

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 463 views
  • 1 like
  • 4 in conversation