BookmarkSubscribeRSS Feed
Bill
Quartz | Level 8
Have this bit of code and I can't figure out how to have control over the "By Category" and "By Location" labels in the table statement.

Help would be greatly appreciated - thanks

proc tabulate data=SlabIm2 format=comma6.0 style=[font_face=helvetica fore_ground=green font_size=7pt];
class SLAB_GRD_FAM_NAME
SLAB_SOURCE_DIM_CD
PROD_GRP_DIM_CD
SLAB_LOC_DIM_CD;

classlev SLAB_GRD_FAM_NAME
SLAB_SOURCE_DIM_CD
PROD_GRP_DIM_CD
SLAB_LOC_DIM_CD/
style=[foreground=red font_face=helvetica font_size=7pt];

var SLAB_TON/style=[foreground=blue font_face=helvetica font_size=6pt];

table SLAB_SOURCE_DIM_CD=' '*
(SLAB_GRD_FAM_NAME=' ' all) all,
(PROD_GRP_DIM_CD='By Category' all SLAB_LOC_DIM_CD='By Location')
*SLAB_TON='Tons'*sum=' '*
[style=[foreground=green font_face=helvetica font_size=8pt]]
/misstext=' '
box=[label="All Slab Inventory"
style=[foreground=orange font_face=helvetica font_size=8pt]]
;
run;
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi, Bill:
The STYLE= option when used on the CLASS statement controls the headers for the CLASS variables. Your code is using a style= option on the CLASSLEV statement == this controls the VALUES for the CLASS variables.

So, depending on what you want, you can either use a STYLE= override to apply to ALL the CLASS variables (same as your CLASSLEV statement)
[pre]
class SLAB_GRD_FAM_NAME
SLAB_SOURCE_DIM_CD
PROD_GRP_DIM_CD
SLAB_LOC_DIM_CD / style=[background=yellow foreground=black];
[/pre]

or you can have multiple CLASS statements:
[pre]
class SLAB_GRD_FAM_NAME
SLAB_SOURCE_DIM_CD / [background=yellow foreground=black];
CLASS PROD_GRP_DIM_CD
/ style=[background=pink foreground=black];
CLASS SLAB_LOC_DIM_CD
/ style=[background=cyan foreground=black];
[/pre]

Proc TABULATE has very specific places that the STYLE= override affects -- so, for example, the style= override in your TABULATE statement affects the data cells (the style attribute is foreground...not fore_ground). What is specified in the TABLE statement affects the whole table. What is specified in the VAR statement affects the headers for the Analysis variables. What is specified in the CLASS statement affects the Class variable headers. If you look up the TABULATE documentation, there is an example of using STYLE= with Proc TABULATE.

cynthia
Bill
Quartz | Level 8
Thanks Cynthia for your help.

I'm not familiar with the pre /pre syntax. Could you explain its relevance please - & thanks.

wd
Cynthia_sas
SAS Super FREQ
Hi, Bill:
I'm not exactly sure what you mean. I like my SAS code to look like code and maintain my indentations when I paste the code into a forum posting. In regular HTML-land, the <pre> and </pre> tags are used to prevent the browser from tampering with the way something has been typed into an HTML page.

In the forum posting, the use of <pre> is not supported -- since the forum itself lives in HTML-land. So the way to paste code and have the indentation maintained in the forum is with [ pre ] and [ /pre ] surrounding the code (but without spaces before and after the [ ] square brackets.

Is that what you meant, or did you mean something else? [ pre ] does NOT go into your SAS code window. I'm surprised you can see it at all. It generally disappears from the forum postings.

cynthia
Bill
Quartz | Level 8
Thanks for the pre /pre explanation. You are correct, I don't see it on the forum, but I could see it in the "watch" email that was sent to me.

And now another question - how do I gain control over the "All" part of the table, both the data and the "All" label?

Thanks again,
wd
Cynthia_sas
SAS Super FREQ
Hi:
If you look in the doc for the explanation of CLASSLEV, you should also see an explanation of the KEYWORD statement. Like CLASSLEV, the KEYWORD statement gives you control over the style of headers for the keyword statistics (just as CLASSLEV gives you control over the style of headers for the levels of the CLASS variables).

For controlling the data cells created by the use of ALL, you can use the "crossing" method in the TABLE statement:
[pre]
TABLE .....,
..... ALL*{s={foreground=black background=yellow}} ...
/box=.....;
[/pre]

You can use either curly braces {} or square brackets [] around your style=specification. Note that, in the TABLE statement, the -ENTIRE- style= override is surrounded by an extra set of curly braces or square brackets.

cynthia

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
  • 779 views
  • 0 likes
  • 2 in conversation