BookmarkSubscribeRSS Feed
scify
Obsidian | Level 7

I'm creating a report that's meant to go out to some of our clients, based on an excel mockup I was given, and I've mostly managed to recreate what I'm being asked for. However, I've hit a (minor, admittedly) stumbling block.

 

The data I'm working with is currently structured as follows:

 

a b c d
text1 num1 text2 num2
... etc

 

and the proc report is written:

 

proc report data=base;
	column ("Header1" (("Subhead1" (a b)) ("Subhead2" (c d))));
	define a / " " style(column)={width=1000%};
	define b / " " style(column)={width=1000%};
	define c / " " style(column)={width=1000%};
	define d / " " style(column)={width=1000%};
quit;

 

which produces:

 

Header1
Subhead1 Subhead2
text1 num1 text2 num2
... etc

 

The stumbling block I've hit is that they've asked that "Header1" be conditionally colored based on some of the values in the data. Changing the style(header) backgroundcolor attribute hits both the header and the subheads, so that won't work. First question, then--is there a more specific attribute that would only hit that Header1 row?

 

If not (which I suspect is the case) the idea I had was to restructure the data so that the Subheads were instead grouping or across variables. When I tried this, however, I got some unexpected results.

 

New data structure:

 

Group a b
Subhead1 text1 num1
Subhead1 ... etc
Subhead2 text2 num2
Subhead2 ... etc

 

New proc report:

 

proc report data=base2;
	column ("Header1" (groups (a b)));
	define groups /  " " style(column)={width=1000%};
	define a / " " style(column)={width=1000%};
	define b / " " style(column)={width=1000%};
quit;

 

which resulted in:

 

Header1
Subhead1 text1 num1
... etc
Subhead2 text2 num2
... etc

 

I then tried changing groups to an across variable in the definition step,

 

proc report data=base2;
	column ("Header1" (groups (a b)));
	define groups / " " across;
	define a / " " style(column)={width=1000%};
	define b / " " style(column)={width=1000%};
quit;

and got the following:

 

Header1
Subhead1 Subhead2    
1   text1 num1
1 ...etc
  1 text2 num2
  1 ...etc

 

which is not what I expected. So, second question: What am I doing wrong here, and how do I fix it?

 

I'm using SAS 9.4.5.0, if that affects things.

1 REPLY 1
Cynthia_sas
Diamond | Level 26

Hi:

  I think the easiest thing for you to do is make some "helper" variables that can be "extra" across variables. For example look in this paper  http://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf on page 12/13  and note how I make some extra helper vars called X and Y and I make the color for X GREEN and the color for Y PEACHPUFF -- if you wanted "Three Values" and "Current" to be the same color, then you'd change my colors on the style override to be the color or style attributes you wanted.

 

Cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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