<?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: proc sql find count and percent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-find-count-and-percent/m-p/853072#M337201</link>
    <description>&lt;P&gt;That's a lot of work to do this in SQL, all you need to do is the join in PROC SQL and then PROC FREQ computes the statistics much easier&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
    table sex*exdstxt/list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 10 Jan 2023 14:47:10 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-01-10T14:47:10Z</dc:date>
    <item>
      <title>proc sql find count and percent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-find-count-and-percent/m-p/853071#M337200</link>
      <description>&lt;P&gt;How can I find count and percent using proc sql? EXDSTXT= treatment. The result table shows percent but not by each separate treatment&lt;/P&gt;
&lt;P&gt;data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    create table M_S as 
    select a.SUBJID,b.EXDSTXT,a.SEX,

            case when SEX= 'M' then 'Male'
                 when SEX= 'F' then 'Female'
                 else ''
                 end as sexcatvar,

            case when b.EXDSTXT='7 ug/kg/day' then 1
                 when b.EXDSTXT='9 ug/kg/day' then 2
                 when b.EXDSTXT='12 ug/kg/day' then 3
                 when b.EXDSTXT='Total' then 4
                 else .
                 end as EXDSN
from Sasfile.Dm as a 
inner join EX as b 
on a.SUBJID=b.SUBJID
;
quit;
proc sql noprint;
    create table FREQST as
        select sexcatvar,EXDSN,EXDSTXT,count(sexcatvar) as COUNT,calculated COUNT/ (select count(*) from M_S) as pct format=percent8.2
        from M_S
        group by sexcatvar,EXDSN,EXDSTXT
        order by EXDSTXT;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;result:&lt;/P&gt;
&lt;DIV id="tinyMceEditorAyooo1_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ayooo1_1-1673361239800.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79230i83EB32218100A54E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ayooo1_1-1673361239800.png" alt="Ayooo1_1-1673361239800.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 14:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-find-count-and-percent/m-p/853071#M337200</guid>
      <dc:creator>Ayooo1</dc:creator>
      <dc:date>2023-01-10T14:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql find count and percent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-find-count-and-percent/m-p/853072#M337201</link>
      <description>&lt;P&gt;That's a lot of work to do this in SQL, all you need to do is the join in PROC SQL and then PROC FREQ computes the statistics much easier&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
    table sex*exdstxt/list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jan 2023 14:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-find-count-and-percent/m-p/853072#M337201</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-10T14:47:10Z</dc:date>
    </item>
  </channel>
</rss>

