<?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: stack statistics of multiple variables in the same table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/403382#M98023</link>
    <description>&lt;P&gt;Transpose (via PROC TRANSPOSE or an array) your data to a long format and then use PROC FREQ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp;Question Answer&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 1 1&lt;/P&gt;
&lt;P&gt;1 2 3&lt;/P&gt;
&lt;P&gt;1 3 5&lt;/P&gt;
&lt;P&gt;1 4 2&lt;/P&gt;
&lt;P&gt;2 1 3&lt;/P&gt;
&lt;P&gt;2 2 3&lt;/P&gt;
&lt;P&gt;2 2 5&lt;/P&gt;
&lt;P&gt;2 4 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also look at SURVEYFREQ though I suspect its the same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/171091"&gt;@XiaoGuaiShou&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I know I could run multiple proc tabulate/freq, output summaries to individual dataset and merge them together. but the situation is I need to make the report all completed by SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Yes, this is an option that you can do WITHIN SAS as well. Not sure what you mean it must be completed by SAS.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2017 22:23:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-10-11T22:23:29Z</dc:date>
    <item>
      <title>stack statistics of multiple variables in the same table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/403375#M98017</link>
      <description>&lt;P&gt;Hello all:&lt;/P&gt;&lt;P&gt;&amp;nbsp; In a project, I hope to create one summary table for multiple variables. &lt;SPAN&gt;For example, I have several Questions with same answer style (level 1-4:very hard, hard, easy, very easy).&amp;nbsp;&lt;/SPAN&gt;My data looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; Question_1 &amp;nbsp; &amp;nbsp; &amp;nbsp;Question_2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Question_3&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; hard&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;v&lt;SPAN&gt;ery hard&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;easy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;very hard&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/STRONG&gt;hard&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hard&amp;nbsp;&lt;/P&gt;&lt;P&gt;......&lt;SPAN&gt;......&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can easily produce a summary table for each one of those variables separately. But what I need is to stack all of them together in the same table like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;variable &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;U&gt;&amp;nbsp;Level (%percentage)&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; very hard &amp;nbsp; &amp;nbsp; &amp;nbsp; hard &amp;nbsp; &amp;nbsp; &amp;nbsp;easy &amp;nbsp; &amp;nbsp; &amp;nbsp;very easy&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Question_1 &lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;32% &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 32% &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;SPAN&gt;32% &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4%&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Question_2&lt;/SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;10&lt;/SPAN&gt;&lt;SPAN&gt;% &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;32% &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; &lt;SPAN&gt;32% &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 26%&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Question_3&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;58% &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;32% &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; 10&lt;SPAN&gt;% &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0%&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I cannot come up with an easy solution with any of proc report, tabulate or freq. I know I could run multiple proc tabulate/freq, output summaries to individual dataset and merge them together. but the situation is I need to make the report all completed by SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 21:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/403375#M98017</guid>
      <dc:creator>XiaoGuaiShou</dc:creator>
      <dc:date>2017-10-11T21:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: stack statistics of multiple variables in the same table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/403382#M98023</link>
      <description>&lt;P&gt;Transpose (via PROC TRANSPOSE or an array) your data to a long format and then use PROC FREQ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp;Question Answer&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 1 1&lt;/P&gt;
&lt;P&gt;1 2 3&lt;/P&gt;
&lt;P&gt;1 3 5&lt;/P&gt;
&lt;P&gt;1 4 2&lt;/P&gt;
&lt;P&gt;2 1 3&lt;/P&gt;
&lt;P&gt;2 2 3&lt;/P&gt;
&lt;P&gt;2 2 5&lt;/P&gt;
&lt;P&gt;2 4 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also look at SURVEYFREQ though I suspect its the same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/171091"&gt;@XiaoGuaiShou&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I know I could run multiple proc tabulate/freq, output summaries to individual dataset and merge them together. but the situation is I need to make the report all completed by SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Yes, this is an option that you can do WITHIN SAS as well. Not sure what you mean it must be completed by SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 22:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/403382#M98023</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-11T22:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: stack statistics of multiple variables in the same table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/403387#M98027</link>
      <description>&lt;P&gt;Here is one way to look at this type of problem.&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines dlm=',';
   informat id $2.   Question_1  Question_2  Question_3 $10.;
   input id     Question_1 Question_2  Question_3;
datalines;
1 ,hard,very hard,easy
2 ,very hard,hard,hard 
3 ,very easy,easy,hard 
4 ,very hard,hard,easy 
5 ,very easy,hard,hard 
6 ,very easy,easy,easy
;
run; 
data want;
   set have;
   array q Question_1 - Question_3;
   do i= 1 to dim (q);
      value=q[i];
      qname= vname(q[i]);
      output;
   end;
   keep id value qname;
run;

proc tabulate data=want;
   class qname value;
   table qname='',
         value*rowpctn=''
   ;
run;&lt;/PRE&gt;
&lt;P&gt;If you have label that provides nicer descriptions of your variables then you could make the length of the Qname variable longer and use qname= vlabel(q[I]);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 22:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/403387#M98027</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-11T22:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: stack statistics of multiple variables in the same table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/408633#M99782</link>
      <description>&lt;P&gt;It is really what I want. So clever way to pivot the table. Thanks so much!!!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 12:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stack-statistics-of-multiple-variables-in-the-same-table/m-p/408633#M99782</guid>
      <dc:creator>XiaoGuaiShou</dc:creator>
      <dc:date>2017-10-30T12:57:36Z</dc:date>
    </item>
  </channel>
</rss>

