<?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: Create table of multiple variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516917#M3254</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248732"&gt;@kenwill&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much! This is very helpful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have added a 'where' statement to filter out the 'warm' category.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=test.table;&lt;BR /&gt;where temperature ~= 'warm';&lt;BR /&gt;class month time temperature;&lt;BR /&gt;table time=' ' all='Total',&lt;BR /&gt;month=' '*temperature=' '*n=' '&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I&amp;nbsp;want just 2 columns for each month: first column for the&amp;nbsp;combined&amp;nbsp;frequency of cool, cold, and freeze (and name the variable as 'not warm'), and the second column for just the freeze frequency. Any advice on how should I approach it? Appreciate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ken&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There are two&amp;nbsp;basic approaches to treating multiple values as a single category for reporting. One is to go back to your data and create an additional variable with if/then/else statements. Which can get tedious repeated visits to keep adding different variables.&lt;/P&gt;
&lt;P&gt;For values based on a &lt;STRONG&gt;single&lt;/STRONG&gt; variable a custom format is often preferable as you need not add any variables and is often easier to write ranges of values for numeric variables. Also a format may be applicable to multiple variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tabulate is one of the few procedures that uses multilabel formats to do such things as group and individual values so that may be the way to go:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $coldtemp (multilabel)
'cool','cold','freeze'= 'not warm'
'freeze' = 'freeze'
;
run;

proc tabulate data=test.table;
   class month time;
   class temperature / mlf;
   format temperature $coldtemp.;
   table time=' ' all='Total',
         month=' '*temperature=' '*n=' '
         ;
run;&lt;/PRE&gt;
&lt;P&gt;However sort order of the formatted values can depend on the order a format is written and the sub groups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Nov 2018 23:51:06 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-11-28T23:51:06Z</dc:date>
    <item>
      <title>Create table of multiple variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516822#M3239</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and would need some expert advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to create a table of 3 variables. The hypothetical data is saved as table.sas7bdat as attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also attached is the report table format I need (see Table.xlsx).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the follow proc freq codes to create the table I want but it gives me 3 separate tables instead. Also, I couldn't produce the column formats I need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data = test.table (where=(temperature not in ('warm')));&lt;BR /&gt;table month*time*temperature / out = class norow nocol nopercent&lt;BR /&gt;;&lt;BR /&gt;run&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise me what's the correct codes to produce the table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, is it possible to use PROC TABULATE&amp;nbsp;or some other approach to create the same table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 18:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516822#M3239</guid>
      <dc:creator>kenwill</dc:creator>
      <dc:date>2018-11-28T18:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create table of multiple variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516867#M3242</link>
      <description>&lt;P&gt;See if this gets you started;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=test.table;
class month time temperature;
table time=' ' all='Total',
      month=' '*temperature=' '*n=' '
      ;
run;&lt;/PRE&gt;
&lt;P&gt;The =' ' after the variables and the n statistic (to count) are to suppress variable name or labels.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can add a WHERE statement to filter data or a where data set option.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 20:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516867#M3242</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-28T20:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create table of multiple variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516883#M3243</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much! This is very helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added a 'where' statement to filter out the 'warm' category.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc tabulate data=test.table;&lt;BR /&gt;where temperature ~= 'warm';&lt;BR /&gt;class month time temperature;&lt;BR /&gt;table time=' ' all='Total',&lt;BR /&gt;month=' '*temperature=' '*n=' '&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I&amp;nbsp;want just 2 columns for each month: first column for the&amp;nbsp;combined&amp;nbsp;frequency of cool, cold, and freeze (and name the variable as 'not warm'), and the second column for just the freeze frequency. Any advice on how should I approach it? Appreciate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 21:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516883#M3243</guid>
      <dc:creator>kenwill</dc:creator>
      <dc:date>2018-11-28T21:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create table of multiple variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516917#M3254</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248732"&gt;@kenwill&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much! This is very helpful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have added a 'where' statement to filter out the 'warm' category.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=test.table;&lt;BR /&gt;where temperature ~= 'warm';&lt;BR /&gt;class month time temperature;&lt;BR /&gt;table time=' ' all='Total',&lt;BR /&gt;month=' '*temperature=' '*n=' '&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I&amp;nbsp;want just 2 columns for each month: first column for the&amp;nbsp;combined&amp;nbsp;frequency of cool, cold, and freeze (and name the variable as 'not warm'), and the second column for just the freeze frequency. Any advice on how should I approach it? Appreciate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ken&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There are two&amp;nbsp;basic approaches to treating multiple values as a single category for reporting. One is to go back to your data and create an additional variable with if/then/else statements. Which can get tedious repeated visits to keep adding different variables.&lt;/P&gt;
&lt;P&gt;For values based on a &lt;STRONG&gt;single&lt;/STRONG&gt; variable a custom format is often preferable as you need not add any variables and is often easier to write ranges of values for numeric variables. Also a format may be applicable to multiple variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tabulate is one of the few procedures that uses multilabel formats to do such things as group and individual values so that may be the way to go:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $coldtemp (multilabel)
'cool','cold','freeze'= 'not warm'
'freeze' = 'freeze'
;
run;

proc tabulate data=test.table;
   class month time;
   class temperature / mlf;
   format temperature $coldtemp.;
   table time=' ' all='Total',
         month=' '*temperature=' '*n=' '
         ;
run;&lt;/PRE&gt;
&lt;P&gt;However sort order of the formatted values can depend on the order a format is written and the sub groups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 23:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516917#M3254</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-28T23:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create table of multiple variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516924#M3255</link>
      <description>&lt;P&gt;It works! I will apply the same approach in future.&amp;nbsp;Thanks very much!!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 00:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-table-of-multiple-variables/m-p/516924#M3255</guid>
      <dc:creator>kenwill</dc:creator>
      <dc:date>2018-11-29T00:35:13Z</dc:date>
    </item>
  </channel>
</rss>

