<?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: getting percent yes/ percent no in columns in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155465#M40836</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have a diffrent approch to do the same ,please have a look ; data have ; input q1 $ q2 $&amp;nbsp; q3 $&amp;nbsp; q4 $&amp;nbsp; ; datalines; yes no yes yes no yes yes no yes yes yes no ; run; proc transpose&amp;nbsp; data = have out = want name = quest; var q1&amp;nbsp;&amp;nbsp;&amp;nbsp; q2&amp;nbsp;&amp;nbsp;&amp;nbsp; q3&amp;nbsp;&amp;nbsp;&amp;nbsp; q4 ; run; data want1 ; set want&amp;nbsp; ; by quest ; array q&amp;nbsp; (3) $ col1- col3 ; if first.quest then&amp;nbsp; count_y = 0 ; do i = 1 to 3 ; if q(i) = "yes" then count = 1 ; else count = 0 ; count_y + count ; end; yes_per = (count_y/3)*100 ; no_per = 100- yes_per&amp;nbsp; ; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Jun 2014 14:15:18 GMT</pubDate>
    <dc:creator>naveen20jan</dc:creator>
    <dc:date>2014-06-26T14:15:18Z</dc:date>
    <item>
      <title>getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155457#M40828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems like this should be easy, but I don't know how yet. I have data like this&lt;/P&gt;&lt;P&gt; q1​&amp;nbsp;&amp;nbsp;&amp;nbsp; q2&amp;nbsp;&amp;nbsp;&amp;nbsp; q3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; q4&lt;/P&gt;&lt;P&gt;yes&amp;nbsp; no&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;/P&gt;&lt;P&gt;no&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;/P&gt;&lt;P&gt;yes&amp;nbsp; yes&amp;nbsp;&amp;nbsp; no&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; no&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each q is a question in a survey. How do I get a table showing percent yes and percent no, for all the questions, like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %yes&amp;nbsp;&amp;nbsp;&amp;nbsp; %no&lt;/P&gt;&lt;P&gt;q1&amp;nbsp;&amp;nbsp;&amp;nbsp; 30%&amp;nbsp;&amp;nbsp;&amp;nbsp; 70%&lt;/P&gt;&lt;P&gt;q2&amp;nbsp;&amp;nbsp;&amp;nbsp; 20%&amp;nbsp;&amp;nbsp;&amp;nbsp; 80%&lt;/P&gt;&lt;P&gt;q3&amp;nbsp;&amp;nbsp;&amp;nbsp; 60%&amp;nbsp;&amp;nbsp;&amp;nbsp; 40%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gene&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 16:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155457#M40828</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2014-06-25T16:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155458#M40829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello geneshackman,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; q1-q4 $3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; q1-q4 $;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id(0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; id + 1;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;yes&amp;nbsp; no&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;/P&gt;&lt;P&gt;no&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;/P&gt;&lt;P&gt;yes&amp;nbsp; yes&amp;nbsp;&amp;nbsp; no&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; no&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set work.have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain id(0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; q{4} q1-q4;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do question=1 to 4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; answer=q{question};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop q1-q4;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq&lt;/P&gt;&lt;P&gt;&amp;nbsp; data=work.want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tables question*answer / nocum nopercent nofreq nocol;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See: &lt;A href="http://support.sas.com/documentation/cdl/en/proc/66663/HTML/default/viewer.htm#p0gbnq9zulpwe5n1s5of0eb6m82b.htm" title="http://support.sas.com/documentation/cdl/en/proc/66663/HTML/default/viewer.htm#p0gbnq9zulpwe5n1s5of0eb6m82b.htm"&gt;Transposing Data for Statistical Analysis :: Base SAS(R) 9.4 Procedures Guide, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 18:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155458#M40829</guid>
      <dc:creator>JasonAllen</dc:creator>
      <dc:date>2014-06-25T18:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155459#M40830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks very much for the suggestion. Would you be able to explain, perhaps in general, what this is doing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 18:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155459#M40830</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2014-06-25T18:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155460#M40831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Gene,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sure.&amp;nbsp; The first data step creates a SAS data set from the data you have, formatted as above, minus the first row which contains what look like column headings.&amp;nbsp; Variables with the same names as the column headings are created.&amp;nbsp; A variable (id) is added to uniquely identify each row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second data step creates a SAS data set containing the data you want, and which can easily be consumed by PROC FREQ.&amp;nbsp; Basically, it creates a row for each unique combination of id, question number (1-4), and answer (yes/no).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FREQ then generates a crosstab (question*answer), and suppresses some output (nocum, etc.).&amp;nbsp; You have a lot of control over what output PROC FREQ generates and also how it is formatted and presented, so if you wanted percentages rounded to the nearest integer you could use the FORMAT= option to specify a format, for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the specific meaning of options "NOCUM", etc., see: &lt;A href="http://support.sas.com/documentation/cdl/en/procstat/66703/HTML/default/viewer.htm#procstat_freq_syntax08.htm" title="http://support.sas.com/documentation/cdl/en/procstat/66703/HTML/default/viewer.htm#procstat_freq_syntax08.htm"&gt;TABLES Statement :: Base SAS(R) 9.4 Procedures Guide: Statistical Procedures, Second Edition&lt;/A&gt;, or just turn them off to see how the output changes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 19:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155460#M40831</guid>
      <dc:creator>JasonAllen</dc:creator>
      <dc:date>2014-06-25T19:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155461#M40832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This may be easy to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input q1 $ q2 $&amp;nbsp; q3 $&amp;nbsp; q4 $;&lt;BR /&gt;datalines;&lt;BR /&gt;yes&amp;nbsp; no&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;BR /&gt;no&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;BR /&gt;yes&amp;nbsp; yes&amp;nbsp;&amp;nbsp; no&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; no&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(keep=vars response);&lt;BR /&gt;set have;&lt;BR /&gt;array q{*} q1 q2 q3 q4;&lt;BR /&gt;do i=1 to dim(q);&lt;BR /&gt; response=q{i};&lt;BR /&gt; vars=vname(q{i});&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc tabulate data=want;&lt;BR /&gt;class response vars;&lt;BR /&gt;table vars=' ' *rowpctn=' ' all= 'Total'*n=' ',response=' ' all='Total';&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 19:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155461#M40832</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-25T19:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155462#M40833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jason. Just fyi, and in case anyone else is interested, I got another suggestion for another way that works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input qu1​&amp;nbsp; $&amp;nbsp; qu2 $&amp;nbsp;&amp;nbsp; qu3 $&amp;nbsp;&amp;nbsp;&amp;nbsp; qu4 $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;yes&amp;nbsp; no&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;/P&gt;&lt;P&gt;no&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;/P&gt;&lt;P&gt;yes&amp;nbsp; yes&amp;nbsp;&amp;nbsp; no&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; no&lt;/P&gt;&lt;P&gt;;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=test out=test1;&lt;/P&gt;&lt;P&gt;var q:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test2 (drop=col:);&lt;/P&gt;&lt;P&gt;set test1;&lt;/P&gt;&lt;P&gt;num_yes=count(cats(of col:),'yes');&lt;/P&gt;&lt;P&gt;num_no=count(cats(of col:),'no');&lt;/P&gt;&lt;P&gt;per_yes=num_yes/(num_yes+num_no);&lt;/P&gt;&lt;P&gt;per_no=num_no/(num_yes+num_no);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=test2 noobs label;&lt;/P&gt;&lt;P&gt;var _name_ per_yes per_no;&lt;/P&gt;&lt;P&gt;label _name_='question' per_yes='%yes' per_no='%no';&lt;/P&gt;&lt;P&gt;format per_yes per_no percent5.0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 19:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155462#M40833</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2014-06-25T19:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155463#M40834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure, no problem.&amp;nbsp; I think SAS, not Perl, was probably the original "There's more than one way to do it" language.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 19:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155463#M40834</guid>
      <dc:creator>JasonAllen</dc:creator>
      <dc:date>2014-06-25T19:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155464#M40835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks "stat" too. Would you also be willing to explain what this is doing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 12:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155464#M40835</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2014-06-26T12:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155465#M40836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have a diffrent approch to do the same ,please have a look ; data have ; input q1 $ q2 $&amp;nbsp; q3 $&amp;nbsp; q4 $&amp;nbsp; ; datalines; yes no yes yes no yes yes no yes yes yes no ; run; proc transpose&amp;nbsp; data = have out = want name = quest; var q1&amp;nbsp;&amp;nbsp;&amp;nbsp; q2&amp;nbsp;&amp;nbsp;&amp;nbsp; q3&amp;nbsp;&amp;nbsp;&amp;nbsp; q4 ; run; data want1 ; set want&amp;nbsp; ; by quest ; array q&amp;nbsp; (3) $ col1- col3 ; if first.quest then&amp;nbsp; count_y = 0 ; do i = 1 to 3 ; if q(i) = "yes" then count = 1 ; else count = 0 ; count_y + count ; end; yes_per = (count_y/3)*100 ; no_per = 100- yes_per&amp;nbsp; ; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 14:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155465#M40836</guid>
      <dc:creator>naveen20jan</dc:creator>
      <dc:date>2014-06-26T14:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155466#M40837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am creating two classification variables one based on variable names and other based on their responses to put them in a crosstab to get desired output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 14:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155466#M40837</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-26T14:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155467#M40838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Naveen, your answer looks like it might be good but I can't tell in the format you have it in. Could you post it again with each command or data step in one row? I tried and couldn't quite straighten out your posting. Something to do with my computer perhaps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gene&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 19:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155467#M40838</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2014-06-26T19:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155468#M40839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the late reply, I had this on a SAS session which crashed yesterday when I was working on it, so am posting this late (note that you could replace the yes_results and no_results with a multi level array, but I kept It like this for simplicity:&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;attrib q1 q2 q3 q4 format=$10.;&lt;BR /&gt;infile cards dlm=',';&lt;BR /&gt;input q1 $ q2 $ q3 $ q4 $;&lt;BR /&gt;cards;&lt;BR /&gt;yes,no,yes,yes&lt;BR /&gt;no,yes,yes,yes&lt;BR /&gt;yes,yes,no,no&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want (drop=i);&lt;BR /&gt;&amp;nbsp; set have end=last;&lt;BR /&gt;&amp;nbsp; attrib quarter format=best. yes no format=$20.;&lt;BR /&gt;&amp;nbsp; array q{4};&lt;BR /&gt;&amp;nbsp; array yes_results{4} (0,0,0,0);&lt;BR /&gt;&amp;nbsp; array no_results{4} (0,0,0,0);&lt;BR /&gt;&amp;nbsp; do i=1 to 4;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if q{i}="yes" then yes_results{i}=yes_results{i}+1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if q{i}="no" then no_results{i}=no_results{i}+1;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; if last then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 4;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quarter=i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yes="%"||strip(put( (yes_results{i} / 4) * 100,best.));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; no="%"||strip(put( (no_results{i} / 4) * 100,best.));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; end; &lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 09:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155468#M40839</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-06-27T09:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: getting percent yes/ percent no in columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155469#M40840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;Hi this will solve the purpose ....&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; q1 $ q2 $&amp;nbsp;&amp;nbsp; q3 $&amp;nbsp; q4 $&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;yes no yes yes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;no yes yes no&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;yes yes yes no&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;transpose&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; = have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; = want &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;name&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; = quest;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; q1&amp;nbsp;&amp;nbsp;&amp;nbsp; q2&amp;nbsp;&amp;nbsp;&amp;nbsp; q3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; q4 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; want1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; want&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; quest ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; q&amp;nbsp; (&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;) $ col1- col3 ; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; first.quest &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; count_y = &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; i = &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; q(i) = &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;"yes"&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; count = &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; ; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; count = &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;count_y + count ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;yes_per = (count_y/&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;)*&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;no_per = &lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;- yes_per&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #575757; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 10:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/getting-percent-yes-percent-no-in-columns/m-p/155469#M40840</guid>
      <dc:creator>naveen20jan</dc:creator>
      <dc:date>2014-06-27T10:23:15Z</dc:date>
    </item>
  </channel>
</rss>

