<?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: Calculate most common issues from survey data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713158#M219963</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279654"&gt;@megsredl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you! The questions are not weighted and there are not any sampling issues that need to be considered. This code gets a table for each variable, but since I have so many variables it would take a long time to manually order the results. Is there a way to export the data from all of those proc freq tables into one new dataset?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want all of the results in a single data set you can use the ODS OUTPUT option&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ods output onewayfreqs = yourdatasetname;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; table&amp;nbsp; q1-q5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output data set will have variable named Table with something like Table Q1 to identify the table request generating the row of data, then a number of additional variables, your variable names with the format used in the freq and another prefixing each of your variables with an F_ . The F_ will be a character version of the formatted value. Not always the prettiest for some purposes.&lt;/P&gt;
&lt;P&gt;This might be helpful:&lt;/P&gt;
&lt;PRE&gt;proc freq data=have;
   ods output onewayfreqs=work.summary;
   tables q1-q5;
   format q1-q5 Not_one.;
run;

data toprint;
  set work.summary;
  onerowlabel = coalescec(of F_:);
  if onerowlabel='Not One';
run;

proc print data=toprint;
   var table onerowlabel frequency percent;
run;
&lt;/PRE&gt;
&lt;P&gt;The data step uses a function, Coalescec to select the first of the F_ values present on the line. the OF says we're going to use a group of variable ans the F_:&amp;nbsp; colon list says "use all the variables whose names start with F_.&lt;/P&gt;
&lt;P&gt;Then the IF keep on the ones that are "not one".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A different format to exclude missing would prevent all the "not one" displays for the other variable rows. But that's hindsight. Exercise for the interested reader: to modify that format to display missing values as " "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jan 2021 18:19:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-01-21T18:19:38Z</dc:date>
    <item>
      <title>Calculate most common issues from survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713129#M219946</link>
      <description>&lt;P&gt;Hello! I am working with a set of survey data. Each question is saved as a variable, and the answers are coded as 1/0 for yes/no or 1/2/3 for always/sometimes/never. There are around 50 questions. Example data below:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $ q1 q2 q3 q4 q5;
datalines;
FacA 1 0 1 2 2
FacB 0 0 3 2 3
FacC 1 1 2 1 3
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm trying to generate a list of the most common issues identified on the survey, i.e. the most common questions with an answer other than 1. How can I create a table with the question number (variable) and the number of survey responses that identified that as an issue? I am using 9.4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the help!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 16:48:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713129#M219946</guid>
      <dc:creator>megsredl</dc:creator>
      <dc:date>2021-01-21T16:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate most common issues from survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713131#M219947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279654"&gt;@megsredl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello! I am working with a set of survey data. Each question is saved as a variable, and the answers are coded as 1/0 for yes/no or 1/2/3 for always/sometimes/never. There are around 50 questions. Example data below:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $ q1 q2 q3 q4 q5;
datalines;
FacA 1 0 1 2 2
FacB 0 0 3 2 3
FacC 1 1 2 1 3
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm trying to generate a list of the most common issues identified on the survey, i.e. the most common questions with an answer other than 1. How can I create a table with the question number (variable) and the number of survey responses that identified that as an issue? I am using 9.4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One relatively easy start is a custom format to group the "not one" values and count them.&lt;/P&gt;
&lt;PRE&gt;proc format;
   value Not_one
1 = 'One'
other = 'Not One'
;

proc freq data=have;
   tables q1-q5;
   format q1-q5 Not_one.;
run;&lt;/PRE&gt;
&lt;P&gt;Groups created by formats in this manner are generally supported by report, graphing and analysis procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question though. Surveys often have weights attached and may come from a complex sample structure. Does that apply to your data?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 16:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713131#M219947</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-21T16:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate most common issues from survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713136#M219949</link>
      <description>&lt;P&gt;Thank you! The questions are not weighted and there are not any sampling issues that need to be considered. This code gets a table for each variable, but since I have so many variables it would take a long time to manually order the results. Is there a way to export the data from all of those proc freq tables into one new dataset?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 17:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713136#M219949</guid>
      <dc:creator>megsredl</dc:creator>
      <dc:date>2021-01-21T17:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate most common issues from survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713158#M219963</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279654"&gt;@megsredl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you! The questions are not weighted and there are not any sampling issues that need to be considered. This code gets a table for each variable, but since I have so many variables it would take a long time to manually order the results. Is there a way to export the data from all of those proc freq tables into one new dataset?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want all of the results in a single data set you can use the ODS OUTPUT option&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ods output onewayfreqs = yourdatasetname;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; table&amp;nbsp; q1-q5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output data set will have variable named Table with something like Table Q1 to identify the table request generating the row of data, then a number of additional variables, your variable names with the format used in the freq and another prefixing each of your variables with an F_ . The F_ will be a character version of the formatted value. Not always the prettiest for some purposes.&lt;/P&gt;
&lt;P&gt;This might be helpful:&lt;/P&gt;
&lt;PRE&gt;proc freq data=have;
   ods output onewayfreqs=work.summary;
   tables q1-q5;
   format q1-q5 Not_one.;
run;

data toprint;
  set work.summary;
  onerowlabel = coalescec(of F_:);
  if onerowlabel='Not One';
run;

proc print data=toprint;
   var table onerowlabel frequency percent;
run;
&lt;/PRE&gt;
&lt;P&gt;The data step uses a function, Coalescec to select the first of the F_ values present on the line. the OF says we're going to use a group of variable ans the F_:&amp;nbsp; colon list says "use all the variables whose names start with F_.&lt;/P&gt;
&lt;P&gt;Then the IF keep on the ones that are "not one".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A different format to exclude missing would prevent all the "not one" displays for the other variable rows. But that's hindsight. Exercise for the interested reader: to modify that format to display missing values as " "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 18:19:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/713158#M219963</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-21T18:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate most common issues from survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/716223#M221310</link>
      <description>Thank you so much for the help, this worked perfectly. I appreciate you taking the time to help!</description>
      <pubDate>Tue, 02 Feb 2021 21:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-most-common-issues-from-survey-data/m-p/716223#M221310</guid>
      <dc:creator>megsredl</dc:creator>
      <dc:date>2021-02-02T21:07:06Z</dc:date>
    </item>
  </channel>
</rss>

