Desktop productivity for business analysts and programmers

color column based on the cell (text) value

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 129
Accepted Solution

color column based on the cell (text) value

Hi All,

 

I need to colour a row based on the text value in the cell value being BBB

 

data test;
	INPUT Target1 $Target2 TRAN;
	Datalines;
AAA 1 1
AAA	  1   1
BBB	  2   73
BBB	 3   2
DDD	 4 5
MVQ	 5 1
OOO	 6 1
OOO	 7 3
OTH	 8 1
OTH	 9 1
TTT	 10 1
TTT  11 5
TTT	 12 1
TTT	 13 2
YYY	 14 1
;
RUN;

Proc Report data=TEST;
	Column Target1 Target2 TRAN TransPCT;
	Define Target1 / DISPLAY 'Target1' style(column)=[cellwidth=4.0in];
	Define Target2 / DISPLAY 'Target2' style(column)=[cellwidth=3.0in];
	define Tran /  DISPLAY 'Transfers' f=comma8. SUM Analysis;
	Define TransPCT / COmputed 'Transfer %' f=Percent8.2;

	Compute Before;
		TransTOT = TRAN.SUM;
	ENDCOMP;

	Compute TransPCT;
		TransPCT = TRAN.sum / TransTOT;
	ENDCOMP;

	Rbreak after / SUmmarize;
RUN;

Current output looks like this, below is what I would like.  Cheers

 

Dean

  

Target1Target2TransfersTransfer %
AAA111.01%
AAA111.01%
BBB27373.74%
BBB322.02%
DDD455.05%
MVQ511.01%
OOO611.01%
OOO733.03%
OTH811.01%
OTH911.01%
TTT1011.01%
TTT1155.05%
TTT1211.01%
TTT1322.02%
YYY1411.01%
  99100.00%

 

Target1Target2TransfersTransfer %
AAA111.01%
AAA111.01%
BBB27373.74%
BBB322.02%
DDD455.05%
MVQ511.01%
OOO611.01%
OOO733.03%
OTH811.01%
OTH911.01%
TTT1011.01%
TTT1155.05%
TTT1211.01%
TTT1322.02%
YYY1411.01%
  99100.00%

Accepted Solutions
Solution
‎03-13-2018 05:18 PM
Super User
Posts: 10,859

Re: color column based on the cell (text) value

Compute TransPCT;
		TransPCT = TRAN.sum / TransTOT;
		if Target1='BBB' then call define(_row_,'style','style={foreground=red}');
	ENDCOMP;

View solution in original post


All Replies
Solution
‎03-13-2018 05:18 PM
Super User
Posts: 10,859

Re: color column based on the cell (text) value

Compute TransPCT;
		TransPCT = TRAN.sum / TransTOT;
		if Target1='BBB' then call define(_row_,'style','style={foreground=red}');
	ENDCOMP;
Super User
Posts: 10,859

Re: color column based on the cell (text) value

data test;
	INPUT Target1 $Target2 TRAN;
	Datalines;
AAA 1 1
AAA	  1   1
BBB	  2   73
BBB	 3   2
DDD	 4 5
MVQ	 5 1
OOO	 6 1
OOO	 7 3
OTH	 8 1
OTH	 9 1
TTT	 10 1
TTT  11 5
TTT	 12 1
TTT	 13 2
YYY	 14 1
;
RUN;


Proc Report data=TEST nowd;
	Column Target1 Target2 TRAN TransPCT;
	Define Target1 / DISPLAY 'Target1' style(column)=[cellwidth=4.0in];
	Define Target2 / DISPLAY 'Target2' style(column)=[cellwidth=3.0in];
	define Tran /  DISPLAY 'Transfers' f=comma8. SUM Analysis;
	Define TransPCT / COmputed 'Transfer %' f=Percent8.2;

	Compute Before;
		TransTOT = TRAN.SUM;
	ENDCOMP;

	Compute TransPCT;
		TransPCT = TRAN.sum / TransTOT;
		if Target1=:'BBB' then call define(_row_,'style','style={foreground=red}');
	ENDCOMP;

	Rbreak after / SUmmarize;
RUN;
Frequent Contributor
Posts: 129

Re: color column based on the cell (text) value

Thanks @Ksharp exactly what I required.

 

Cheers

 

Dean

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 135 views
  • 0 likes
  • 2 in conversation