<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Last column in Proc Tabulate must be in Yellow color in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822455#M324783</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* HAVE */
proc format;
   value myfmt 12='12';
   value mycol 12='Yellow';
run;

data have(keep=Make Model Cylinders);
	set sashelp.cars; 
	if make in ('Audi','BMW','Volkswagen','Mercedes-Benz') then output;
run;

proc sort data=have;
	by Make Model;
run;

PROC TABULATE DATA=WORK.HAVE;
	CLASS Cylinders Make Model;
	classlev Cylinders / s={background=mycol.};
	keyword N / s=&amp;lt; parent &amp;gt;;
    format Cylinders myfmt.;
	keylabel all="Total";
	TABLE 
		(Make * (Model all = 'Total' )	all = 'Total' ),
		Cylinders*n*{style=&amp;lt;parent&amp;gt;} all = 'Total' ;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1657451243395.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73104i0954BA3E6A567F85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1657451243395.png" alt="Ksharp_0-1657451243395.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 10 Jul 2022 11:07:26 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-07-10T11:07:26Z</dc:date>
    <item>
      <title>Last column in Proc Tabulate must be in Yellow color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822445#M324776</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* HAVE */
proc format;
   value myfmt 12='12';
   value mycol 12='Yellow';
run;

data have(keep=Make Model Cylinders);
	set sashelp.cars; 
	if make in ('Audi','BMW','Volkswagen','Mercedes-Benz') then output;
run;

proc sort data=have;
	by Make Model;
run;

PROC TABULATE DATA=WORK.HAVE;
	CLASS Cylinders Make Model;
	classlev Cylinders / s={background=mycol.};
	keyword N / s=&amp;lt; parent &amp;gt;;
    format Cylinders myfmt.;
	keylabel all="Total";
	TABLE 
		(Make * (Model all = 'Total' )	all = 'Total' ),
		Cylinders all = 'Total' ;
RUN;

/* WANT */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="WANT the column like this..." style="width: 379px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73101i1479C86ED4EC4139/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WANT.PNG" alt="WANT the column like this..." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;WANT the column like this...&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I Want the whole last column to be in yellow, not only the headers...&lt;/P&gt;
&lt;P&gt;How do I do that?&lt;/P&gt;
&lt;P&gt;Please see the picture. I want it to be like that... but i'm stuck!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the help or tips!&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jul 2022 21:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822445#M324776</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-07-09T21:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Last column in Proc Tabulate must be in Yellow color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822455#M324783</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* HAVE */
proc format;
   value myfmt 12='12';
   value mycol 12='Yellow';
run;

data have(keep=Make Model Cylinders);
	set sashelp.cars; 
	if make in ('Audi','BMW','Volkswagen','Mercedes-Benz') then output;
run;

proc sort data=have;
	by Make Model;
run;

PROC TABULATE DATA=WORK.HAVE;
	CLASS Cylinders Make Model;
	classlev Cylinders / s={background=mycol.};
	keyword N / s=&amp;lt; parent &amp;gt;;
    format Cylinders myfmt.;
	keylabel all="Total";
	TABLE 
		(Make * (Model all = 'Total' )	all = 'Total' ),
		Cylinders*n*{style=&amp;lt;parent&amp;gt;} all = 'Total' ;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1657451243395.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73104i0954BA3E6A567F85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1657451243395.png" alt="Ksharp_0-1657451243395.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2022 11:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822455#M324783</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-10T11:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Last column in Proc Tabulate must be in Yellow color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822462#M324785</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;! &lt;BR /&gt;We are almost there... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;BR /&gt;Now if I select only Mercedes, like in the code below, and it (the N?) has also a value with '12' in another column,&lt;/P&gt;
&lt;P&gt;than that field in the other column will get the yellow color also ... how do I supress that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at mij output, to see what I mean:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value myfmt 12=12;
   value mycol 12='Yellow';
run;

data have(keep=Make Model Cylinders);
	set sashelp.cars; 
	if make in ('Mercedes-Benz') then output;
run;

proc sort data=have;
	by Make Model;
run;

PROC TABULATE DATA=WORK.HAVE;
	CLASS Cylinders Make Model;
	classlev Cylinders / s={background=mycol.};
	keyword N / s=&amp;lt; parent &amp;gt;;
    format Cylinders myfmt.;
	keylabel all="Total";
	TABLE 
		(Make * (Model all = 'Total' )	all = 'Total' ),
		Cylinders*n*{style=&amp;lt;parent&amp;gt;};
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will produce:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="WANT2.PNG" style="width: 255px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73108i27B53E360EAB7198/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WANT2.PNG" alt="WANT2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2022 11:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822462#M324785</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-07-10T11:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Last column in Proc Tabulate must be in Yellow color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822465#M324787</link>
      <description>&lt;P&gt;OK. You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
   value mycol 12='Yellow';
   value fmt low-high='white';
run;

data have(keep=Make Model Cylinders);
	set sashelp.cars; 
	if make in ('Mercedes-Benz') then output;
run;

proc sort data=have;
	by Make Model;
run;

PROC TABULATE DATA=WORK.HAVE style=header;
	CLASS Cylinders Make Model;
	classlev Cylinders / s={background=mycol.};
	keyword N / s=&amp;lt; parent &amp;gt;;
	keylabel all="Total";
	TABLE 
		(Make * (Model all ={Label='Total' style={BACKGROUND=lightred}} * {STYLE={BACKGROUND=lightred}} )	
ALL={Label='Total' style={BACKGROUND=lightred}} * {STYLE={BACKGROUND=lightred}} ),
		Cylinders*n*{style=&amp;lt;parent&amp;gt;}/style_precedence=row;
RUN;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1657457824742.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73109i8B71A5E1FFCC1E7A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1657457824742.png" alt="Ksharp_0-1657457824742.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2022 12:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822465#M324787</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-10T12:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Last column in Proc Tabulate must be in Yellow color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822470#M324790</link>
      <description>&lt;P&gt;That cheating&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It works good as long as the data remains as is... right?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose the data becomes this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc format;
   value mycol 12='Yellow';
run;

data have(keep=Make Model Cylinders);
	set sashelp.cars;
 	if make in ('Mercedes-Benz') then output;
run;

proc sql;
    insert into work.have
        values("Mercedes-Benz", "E501", 8)
	    values("Mercedes-Benz", "E501", 8)
	    values("Mercedes-Benz", "E501", 8)
	    values("Mercedes-Benz", "E501", 8)
        values("Mercedes-Benz", "E501", 8)
	    values("Mercedes-Benz", "E501", 8)
	    values("Mercedes-Benz", "E501", 8)
	    values("Mercedes-Benz", "E501", 8)
        values("Mercedes-Benz", "E501", 8)
	    values("Mercedes-Benz", "E501", 8)
	    values("Mercedes-Benz", "E501", 8)
		values("Mercedes-Benz", "E501", 8);
quit;

proc sort data=have;
	by Make Model;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then your code won't work. Look:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TABULATE DATA=WORK.HAVE style=header;
	CLASS Cylinders Make Model;
	classlev Cylinders / s={background=mycol.};
	keyword N / s=&amp;lt; parent &amp;gt;;
	keylabel all="Total";
	TABLE 
		(Make * (Model all ={Label='Total' style={BACKGROUND=lightred}} * {STYLE={BACKGROUND=lightred}} )	
ALL={Label='Total' style={BACKGROUND=lightred}} * {STYLE={BACKGROUND=lightred}} ),
		Cylinders*n*{style=&amp;lt;parent&amp;gt;}/style_precedence=row;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will now give:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS_Question_0-1657460272216.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73111iCF0F18CFA4B568AC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAS_Question_0-1657460272216.png" alt="SAS_Question_0-1657460272216.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2022 13:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822470#M324790</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-07-10T13:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Last column in Proc Tabulate must be in Yellow color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822479#M324792</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/195211"&gt;@SAS_Question&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;That cheating&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It works good as long as the data remains as is... right?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually I would say your question is "cheating". You have not provided a general RULE but single example values. So anything other than exactly your example values does not a good chance at a clean general solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One problem is assigning a format to general statistic, n. That can occur in multiple places so is likely not a good "solution" except to specific data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want an extremely specific control on the appearance you may have to summarize the data and use a different approach to creating the output such as the Report Writing Interface in a data step that allows all sorts of conditional statements to set styles based on variable/value combinations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2022 19:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822479#M324792</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-10T19:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Last column in Proc Tabulate must be in Yellow color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822482#M324793</link>
      <description>&lt;P&gt;You are right&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought there was something for the proc tabulate that I might have missed, because of my struggle with this issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But even if it is a very wonderful tool (the proc tabulate) it lacks something (like coloring the way YOU want it, not the way the data wants it).&lt;/P&gt;
&lt;P&gt;So maybe I should do a Proc Report research for this job..&lt;/P&gt;
&lt;P&gt;If you have any tips where to start, it might help!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks anyways!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2022 21:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822482#M324793</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-07-10T21:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Last column in Proc Tabulate must be in Yellow color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822530#M324811</link>
      <description>&lt;P&gt;OK. I think you need to change the type of variable "Cylinders" to avoid the conflict with keyword "N" .&lt;/P&gt;
&lt;P&gt;And try this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have(keep=Make Model Cylinders);
 set sashelp.cars;
  if make in ('Mercedes-Benz') then output;
run;
proc sql;
    insert into work.have
        values("Mercedes-Benz", "E501", 8)
     values("Mercedes-Benz", "E501", 8)
     values("Mercedes-Benz", "E501", 8)
     values("Mercedes-Benz", "E501", 8)
        values("Mercedes-Benz", "E501", 8)
     values("Mercedes-Benz", "E501", 8)
     values("Mercedes-Benz", "E501", 8)
     values("Mercedes-Benz", "E501", 8)
        values("Mercedes-Benz", "E501", 8)
     values("Mercedes-Benz", "E501", 8)
     values("Mercedes-Benz", "E501", 8)
  values("Mercedes-Benz", "E501", 8);
quit;
proc sort data=have;
 by Make Model;
run;



proc format;
   value $ mycol '12'='Yellow';
run;
data have;
 set have;
 _Cylinders=put(Cylinders,best. -l);
 drop Cylinders;
run;

PROC TABULATE DATA=WORK.HAVE order=data;
 CLASS _Cylinders Make Model;
 classlev _Cylinders / s={background=$mycol.} ;
 keyword N / s=&amp;lt; parent &amp;gt;;
 keylabel all="Total";
 TABLE 
  (Make * (Model all = 'Total' ) all = 'Total' ),
  _Cylinders*n*{style=&amp;lt;parent&amp;gt;};
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1657540013551.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73127iC66FCF6161E8671E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1657540013551.png" alt="Ksharp_0-1657540013551.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 11:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-column-in-Proc-Tabulate-must-be-in-Yellow-color/m-p/822530#M324811</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-11T11:46:56Z</dc:date>
    </item>
  </channel>
</rss>

