<?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 calculate percentage in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856840#M338536</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;how do i calculate percentage of the below ,per field. using proc freq or proc sql&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;PROC SQL;
TITLE 'NPS_2022101';
CREATE TABLE DATA_QUALITY_202210 AS 
SELECT COUNT (*) AS COUNT 
	,	COUNT (CASE WHEN CELLPHONE_NO IS NULL THEN 1 END)AS BLANKS
	,	COUNT (CASE WHEN CELLPHONE_NO = '00' THEN 1 END) AS DOES_NOT_COMPLY
	,	COUNT (CASE WHEN CELLPHONE_NO ^= '00' AND CELLPHONE_NO ^= '' THEN 1 END) AS COMPLY_WITH_RULE

FROM VIEWS;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;desired outcome.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rixile106_1-1675347040360.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80028iDB22AD3F37F64EA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rixile106_1-1675347040360.png" alt="Rixile106_1-1675347040360.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2023 14:11:27 GMT</pubDate>
    <dc:creator>Rixile106</dc:creator>
    <dc:date>2023-02-02T14:11:27Z</dc:date>
    <item>
      <title>calculate percentage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856840#M338536</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;how do i calculate percentage of the below ,per field. using proc freq or proc sql&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;PROC SQL;
TITLE 'NPS_2022101';
CREATE TABLE DATA_QUALITY_202210 AS 
SELECT COUNT (*) AS COUNT 
	,	COUNT (CASE WHEN CELLPHONE_NO IS NULL THEN 1 END)AS BLANKS
	,	COUNT (CASE WHEN CELLPHONE_NO = '00' THEN 1 END) AS DOES_NOT_COMPLY
	,	COUNT (CASE WHEN CELLPHONE_NO ^= '00' AND CELLPHONE_NO ^= '' THEN 1 END) AS COMPLY_WITH_RULE

FROM VIEWS;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;desired outcome.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rixile106_1-1675347040360.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80028iDB22AD3F37F64EA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rixile106_1-1675347040360.png" alt="Rixile106_1-1675347040360.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 14:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856840#M338536</guid>
      <dc:creator>Rixile106</dc:creator>
      <dc:date>2023-02-02T14:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: calculate percentage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856858#M338542</link>
      <description>&lt;P&gt;Percents are easily calculated in PROC FREQ (assuming that the percents must add to 100%). If you can show us the original data, we could provide code.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 15:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856858#M338542</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-02T15:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: calculate percentage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856860#M338544</link>
      <description>&lt;P&gt;as per your request see below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE VIEWS AS&lt;BR /&gt;select&amp;nbsp; SUBSTR ((RelatedPartyTel_Number_Cell),1,2) AS CELLPHONE_NO&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;FROM BCC.NPS_EXTRACT_2022101;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 15:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856860#M338544</guid>
      <dc:creator>Rixile106</dc:creator>
      <dc:date>2023-02-02T15:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: calculate percentage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856861#M338546</link>
      <description>&lt;P&gt;Data have;&lt;/P&gt;&lt;P&gt;input RelatedPartyTel_Number_Cell $;&lt;/P&gt;&lt;P&gt;0214675442&lt;/P&gt;&lt;P&gt;0110767466&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0005678653;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 15:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856861#M338546</guid>
      <dc:creator>Rixile106</dc:creator>
      <dc:date>2023-02-02T15:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: calculate percentage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856866#M338549</link>
      <description>&lt;P&gt;If you can, in plain English, state the rules you want to use, these are easily turned into SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in this case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp;&lt;SPAN&gt;RelatedPartyTel_Number_Cell is null then blank&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if&amp;nbsp;RelatedPartyTel_Number_Cell begins with '00' then does_not_comply&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if&amp;nbsp;RelatedPartyTel_Number_Cell does not begin with '00' and not blank then comply_with_rule&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS CODE&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
    set have;
    length type $ 15;
    if RelatedPartyTel_Number_Cell=' ' then type='Blank';
    else if RelatedPartyTel_Number_Cell=:'00' then type='Does Not Comply';
    else type='Comply With Rule';
run;

proc freq data=have2;
    tables type;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The "begins with" in SAS data steps is the =: (equal followed by colon) operator&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 15:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-percentage/m-p/856866#M338549</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-02T15:36:55Z</dc:date>
    </item>
  </channel>
</rss>

