<?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: Output Top 5 Reasons for Survey Answer in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303855#M64606</link>
    <description>&lt;P&gt;No, you're transposing from wide to long so it will handle multiple variables at once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2016 19:34:32 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-10-11T19:34:32Z</dc:date>
    <item>
      <title>Output Top 5 Reasons for Survey Answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303837#M64597</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help with displaying survey results data. &amp;nbsp;Part of the survey asked the employees the reason why they wanted to work for this particular organization. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance, the &lt;STRONG&gt;Survey&lt;/STRONG&gt; question would look like this:&lt;/P&gt;&lt;P&gt;Rate the following reasons why you want to work for this particular organization (best score from 1&amp;nbsp;to 5):&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Closeness to Home&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Diverse Culture&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Supportive Environment&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Etc. etc.&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Due to data privacy issues, I can only show an example of the &lt;STRONG&gt;dataset&lt;/STRONG&gt; using dummy values&amp;nbsp;as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EMPID&lt;/TD&gt;&lt;TD&gt;Department&lt;/TD&gt;&lt;TD&gt;Close_to_Home&lt;/TD&gt;&lt;TD&gt;Diversity&lt;/TD&gt;&lt;TD&gt;Supportive_Environment&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;001&lt;/TD&gt;&lt;TD&gt;Knitting&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;002&lt;/TD&gt;&lt;TD&gt;Knitting&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;003&lt;/TD&gt;&lt;TD&gt;Sewing&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;004&lt;/TD&gt;&lt;TD&gt;Sewing&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;005&lt;/TD&gt;&lt;TD&gt;Sewing&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the show&amp;nbsp;the top reasons for working by department. &amp;nbsp;This is done by taking the average of scores for each item and ranking the scores.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Knitting Department,&lt;/P&gt;&lt;P&gt;Avg Score for Close_to_home = (3+5)/2 = 4;&lt;/P&gt;&lt;P&gt;Avg Diversity = (5+1)/2 = 3;&lt;/P&gt;&lt;P&gt;Avg Support = 2&lt;/P&gt;&lt;P&gt;So the top 2 (or however many) reasons for wanting to work at the organization for this dept is closeness to home and diversity.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the report would need to show something like:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Top 2 for Knitting Department&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;closeness to home&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;diversity&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used&amp;nbsp;Proc Means to calculate the mean score by department, which successfully gives me the calculations. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc means data = data (keep= id cohort_year &amp;amp;keeplist);&lt;BR /&gt;var _numeric_;&lt;BR /&gt;output out=calc sum= mean= /autoname;&lt;BR /&gt;where cohort_year = 2016;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;However, I can't figure out how to display the result in the above format. &amp;nbsp;I could use proc freq, but that only applies to sorting within the same var. &amp;nbsp;Here we have multiple vars and we are comparing the mean between them. &amp;nbsp;Should I use Proc Transpose? &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;I should also add that&amp;nbsp;each var has its own labeling (i.e., close_to_home is already labeled as '&lt;SPAN&gt;closeness to home').&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;Thank you so much for any advice you can give!&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 17:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303837#M64597</guid>
      <dc:creator>lin39</dc:creator>
      <dc:date>2016-10-11T17:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Output Top 5 Reasons for Survey Answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303842#M64599</link>
      <description>&lt;P&gt;Still not quite sure what you are looking for but one hint might be to include a CLASS variable for your Department. That willl give you the requested summaries for each department (and possibly year if that's of interest and included as class).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you get to stuff (technical term) like "top 3" then you often may need to send the output of one procedure into another procedure&amp;nbsp;or a data step to filter, especially if the rules get complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With your example I would likely transpose the data to look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;EMPID Department Topic                   Value    
001 Knitting Close_to_Home               3  
001 Knitting Diversity                   5 
001 Knitting Supportive_Environment      2 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then run Proc Means/summary with Department and Topic as CLass variables then sort by the mean of value descending. Then possibly use a data step or Proc Rank to add ranking variables before printing the results with Proc Print.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 14:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303842#M64599</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-12T14:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Output Top 5 Reasons for Survey Answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303848#M64602</link>
      <description>&lt;P&gt;Thank you so much for your input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a final output as follows, one for every department. &amp;nbsp;We have about 20 depts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Top 2 for Knitting Department&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;closeness to home&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;diversity&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think what you suggested should work. &amp;nbsp;However, reason for wanting to work at the organization are based not only on the three topics I showed in my example but a total of 23 topics. &amp;nbsp;proc transpose only does one variable at a time, am I correct? &amp;nbsp;How do I make this more efficient?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your&amp;nbsp;time!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 19:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303848#M64602</guid>
      <dc:creator>lin39</dc:creator>
      <dc:date>2016-10-11T19:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Output Top 5 Reasons for Survey Answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303855#M64606</link>
      <description>&lt;P&gt;No, you're transposing from wide to long so it will handle multiple variables at once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 19:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303855#M64606</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-11T19:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Output Top 5 Reasons for Survey Answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303888#M64622</link>
      <description>&lt;P&gt;Oh! &amp;nbsp;It worked like a charm!&amp;nbsp;&lt;img id="catvery-happy" class="emoticon emoticon-catvery-happy" src="https://communities.sas.com/i/smilies/16x16_cat-very-happy.png" alt="Cat Very Happy" title="Cat Very Happy" /&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is as follows! &amp;nbsp;Thanks so much to both of you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sort data=out;
by dept empid;
run;

proc transpose data=out out=out2;
by dept empid;
id cohort_year;
run;

proc means data=out2 stackodsoutput mean;
class dept _label_;
var _2016;
ods output summary=top5_reason (drop = _control_);
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 21:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Top-5-Reasons-for-Survey-Answer/m-p/303888#M64622</guid>
      <dc:creator>lin39</dc:creator>
      <dc:date>2016-10-11T21:17:55Z</dc:date>
    </item>
  </channel>
</rss>

