<?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: Collating Proc Freq Table Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/440954#M282557</link>
    <description>&lt;P&gt;You should be able to get that directly from the data.&amp;nbsp; Getting the right denominator for percentages can be tricky, so see if this fits what you are asking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=have;&lt;/P&gt;
&lt;P&gt;class activity_type organisation plus a few more;&lt;/P&gt;
&lt;P&gt;tables organization plus a few more,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; activity_type * pctn &amp;lt;activity_type&amp;gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2018 17:04:02 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-02-28T17:04:02Z</dc:date>
    <item>
      <title>Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/440948#M282555</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a feeling the solution I'm hoping for doesn't exist/isn't possible, but here goes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- I have a dataset with 21 variables, one of which is ACTIVITY_TYPE which has 5 possible values - 1/2/3/4/5&lt;/P&gt;&lt;P&gt;- I want to look at all of the other variables against ACTIVITY_TYPE - what are the proportions of their responses across ACTIVITY TYPE?&lt;/P&gt;&lt;P&gt;- EG; one of the variables is 'Organisation' - A/B/C/D. I want to see for each of A/B/C/D what % is ACTIVITY_TYPE 1/2/3/4/5&lt;/P&gt;&lt;P&gt;- I have used PROC FREQ to get such a one way frequency analysis (it is only the 'col pct' and 'frequency' that I am interested in)&lt;/P&gt;&lt;P&gt;- I know I can use PROC FREQ to output multiple tables showing the results, but I will then be left with manual process to bring them together in one table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Is there any way to shorten this? I am using EG.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 16:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/440948#M282555</guid>
      <dc:creator>jagnew</dc:creator>
      <dc:date>2018-02-28T16:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/440950#M282556</link>
      <description>&lt;P&gt;Use the ODS table and clean that up.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output crosstabfreqs=summary;
proc freq data=sashelp.class;
table sex*(_all_);
run;

proc print data=summary;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And heres an attempt at cleaning it up:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output crosstabfreqs=summary;
proc freq data=sashelp.class;
table sex*(_all_);
run;



data long;
	length variable $32. variable_value $50.;
	set summary;
	Variable=scan(table, 2, '*');
	Variable_Value=strip(trim(vvaluex(variable)));
	presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
	keep sex variable  variable_value frequency percent presentation;
	label variable='Variable' variable_value='Variable Value';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 16:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/440950#M282556</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-28T16:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/440954#M282557</link>
      <description>&lt;P&gt;You should be able to get that directly from the data.&amp;nbsp; Getting the right denominator for percentages can be tricky, so see if this fits what you are asking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=have;&lt;/P&gt;
&lt;P&gt;class activity_type organisation plus a few more;&lt;/P&gt;
&lt;P&gt;tables organization plus a few more,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; activity_type * pctn &amp;lt;activity_type&amp;gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 17:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/440954#M282557</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-28T17:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441116#M282558</link>
      <description>&lt;P&gt;Here's a little amplification of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s suggestion, which produces both N and column frequencies.&amp;nbsp; PROC TABULATE is not entirely intuitive, but addresses your request for combined tables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input atype b $  c sex $ e;
datalines;
1 X 1 M 1
1 X 2 M 1
1 Y 3 M 5
2 Y 1 F 2
2 C 2 F 3
3 D 3 M 3
3 X 1 M 3
3 Y 2 F 1
3 Y 3 F 1
4 D 1 M 2
4 X 2 F 2
5 C 3 F 2
5 C 1 F 1
5 D 2 F 1
5 D 3 F 1
5 D 1 M 1
run;

proc tabulate data=have noseps;
  class atype b c sex e;
  tables
    (b='VarB' c='VarC' sex='Sex' e='Var E')
     *(N*f=8.0 pctn&amp;lt;atype all&amp;gt;='%'*f=8.1)
	,
    (atype='A Type Pcts' all)
  /rts=12 row=float;
run; 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Mar 2018 04:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441116#M282558</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-01T04:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441184#M282559</link>
      <description>&lt;P&gt;Thanks Astounding. I think this is the right method/solution as it is close to what I need. However I am having issues with some of the variables only showing 1 value in the output - while some variables correctly show all their values....&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 13:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441184#M282559</guid>
      <dc:creator>jagnew</dc:creator>
      <dc:date>2018-03-01T13:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441190#M282560</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;, apologies if I'm being dumb but what exactly are you doing in the tables statement? Thanks</description>
      <pubDate>Thu, 01 Mar 2018 14:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441190#M282560</guid>
      <dc:creator>jagnew</dc:creator>
      <dc:date>2018-03-01T14:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441199#M282561</link>
      <description>&lt;P&gt;There are a couple of possibilities to investigate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, PROC TABULATE automatically removes observations that have a missing value for any of the CLASS variables.&amp;nbsp; You would need to add the MISSING option to include those observations.&amp;nbsp; It's particularly devious, because if variable A has a missing value, that observation is removed even for computing&amp;nbsp;the distribution of variable B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A second possibility to investigate:&amp;nbsp; do any of the CLASS variables have formats attached to them?&amp;nbsp; PROC CONTENTS would reveal that.&amp;nbsp; Formats can group many values into a single row in the output table.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 14:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441199#M282561</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-01T14:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441210#M282562</link>
      <description>Adding the MISSING option worked! Thank you, this has been very helpful&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Mar 2018 14:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441210#M282562</guid>
      <dc:creator>jagnew</dc:creator>
      <dc:date>2018-03-01T14:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Collating Proc Freq Table Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441211#M282563</link>
      <description>Thanks Reeza, I haven't been able to get my head around this yet but I will have a look soon</description>
      <pubDate>Thu, 01 Mar 2018 14:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collating-Proc-Freq-Table-Values/m-p/441211#M282563</guid>
      <dc:creator>jagnew</dc:creator>
      <dc:date>2018-03-01T14:58:29Z</dc:date>
    </item>
  </channel>
</rss>

