<?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: How to display both formatted and unformatted variables in Proc Tabulate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418997#M102977</link>
    <description>Hi thanks all! Actually it worked with or without the $, so that's why I'm curious about it.</description>
    <pubDate>Wed, 06 Dec 2017 23:38:09 GMT</pubDate>
    <dc:creator>LL5</dc:creator>
    <dc:date>2017-12-06T23:38:09Z</dc:date>
    <item>
      <title>How to display both formatted and unformatted variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418940#M102960</link>
      <description>&lt;P&gt;Hi All, I have variable named color in the dataset test shown as below. I also have a Proc Format to assign a value to each different color. My end goal is to display the variables of both&amp;nbsp;color and color_new&amp;nbsp;in the proc tabulate shown as below.&amp;nbsp;I think Proc Report might be able to achieve this goal, but&amp;nbsp;is there anyway to do it in Proc Tabulate? Thanks for any of your advices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; TEST;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;LENGTH&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; COLOR $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;INPUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; COLOR$ PRICE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CARDS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BLUE 75&lt;/P&gt;&lt;P&gt;ORANGE 200&lt;/P&gt;&lt;P&gt;BLACK 300&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;FORMAT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;VALUE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; $COLOR_NEW&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"BLUE"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; =&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"HIGH"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"ORANGE"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; =&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"MID"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"BLACK"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"LOW"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below two Proc Tabulate could only&amp;nbsp;display one variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;TABULATE&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;DATA&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=TEST;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;VAR&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; PRICE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CLASS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; COLOR;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; COLOR , PRICE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;TABULATE&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;DATA&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=TEST;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FORMAT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; COLOR &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$COLOR_NEW.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;VAR&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; PRICE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CLASS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; COLOR;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; COLOR , PRICE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;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TD&gt;&lt;P&gt;200&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 20:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418940#M102960</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2017-12-06T20:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to display both formatted and unformatted variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418950#M102962</link>
      <description>&lt;P&gt;How about something like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA NEWDATA;
	SET TEST;
	COLOR_NEW = COLOR;
RUN;


PROC TABULATE DATA=NEWDATA;
	FORMAT COLOR_NEW $COLOR_NEW.;
	VAR PRICE;
	CLASS COLOR COLOR_NEW;
	TABLE COLOR*COLOR_NEW , PRICE;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 20:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418950#M102962</guid>
      <dc:creator>derekg</dc:creator>
      <dc:date>2017-12-06T20:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to display both formatted and unformatted variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418952#M102963</link>
      <description>&lt;P&gt;To display an additional column in the row header in proc tabulate you would need to add a new variable:&lt;/P&gt;
&lt;PRE&gt;PROC FORMAT;
   VALUE $COLOR_NEW
   "BLUE" ="HIGH"
   "ORANGE" ="MID"
   "BLACK" = "LOW"
   ;
RUN;
DATA TEST;
   LENGTH COLOR $6;
   INPUT COLOR$ PRICE;
   color_new = put(color,color_new.);
CARDS;
 
BLUE 75
ORANGE 200
BLACK 300
;
RUN;
 
PROC TABULATE DATA=TEST;
   VAR PRICE;
   CLASS COLOR color_new;
   TABLE COLOR*color_new , PRICE;
RUN;
&lt;/PRE&gt;
&lt;P&gt;Other approaches in Proc Tabulate are likely to run into issues with appearance except fixed width fonts if you want a nice alignment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc report may be more appropriate if you only want one variable in your data set as you can create a column with calculated values referencing other variables.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 17:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418952#M102963</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-13T17:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to display both formatted and unformatted variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418970#M102965</link>
      <description>&lt;P&gt;Thanks, Ballardw. Now I realize a new variable must be added in order to be displayed in Proc Tabulate. Can you advise me how would I do it in Proc Report?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 21:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418970#M102965</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2017-12-06T21:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to display both formatted and unformatted variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418976#M102967</link>
      <description>&lt;P&gt;You could use a compute block in Proc Report:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=test;
	columns color color2 price;
	define color / display;
	define color2 / computed;
	define price / display;
	compute color2 / character;
		color2 = put(color, color_new.);
	endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 22:17:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418976#M102967</guid>
      <dc:creator>derekg</dc:creator>
      <dc:date>2017-12-06T22:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to display both formatted and unformatted variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418982#M102969</link>
      <description>&lt;P&gt;Thanks Dereky for your codes. May I ask why we don't need the dollar sign in front of color_new?&lt;/P&gt;&lt;P&gt;color2 &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;color&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; color_new&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 22:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418982#M102969</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2017-12-06T22:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to display both formatted and unformatted variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418992#M102975</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89004"&gt;@LL5&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Dereky for your codes. May I ask why we don't need the dollar sign in front of color_new?&lt;/P&gt;
&lt;P&gt;color2 &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;color&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; color_new&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;typo. the format should include the $.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could run the code and get the error message if you want to test if the code is valid as presented. We are human and will make mistakes especially when using names/ name style we don't normally use.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 23:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418992#M102975</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-06T23:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to display both formatted and unformatted variables in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418997#M102977</link>
      <description>Hi thanks all! Actually it worked with or without the $, so that's why I'm curious about it.</description>
      <pubDate>Wed, 06 Dec 2017 23:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-both-formatted-and-unformatted-variables-in-Proc/m-p/418997#M102977</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2017-12-06T23:38:09Z</dc:date>
    </item>
  </channel>
</rss>

