<?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: Percentage display in datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328308#M73292</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;This seems to work for me

HAVE

Up to 40 obs WORK.HAVE total obs=3

Obs            PCT2

 1            0.101
 2            0.201
 3            0.301

WANT

Obs    PCT

 1     10%
 2     20%
 3     30%


SOLUTION

* create some data;
data have;
 do pct2=.101 to .301 by .1;
    output;
 end;
run;quit;

* format new variable;
data want;
set have;
format pct percent.;
pct=pct2;
drop pct2;
run;

* print with format;
proc print data=want;
run;quit;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Jan 2017 00:46:57 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2017-01-30T00:46:57Z</dc:date>
    <item>
      <title>Percentage display in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328307#M73291</link>
      <description>&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; app_summary02;&lt;/P&gt;
&lt;P&gt;set app_summary2;&lt;/P&gt;
&lt;P&gt;pct2=round(pct);&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rounded output example&lt;/P&gt;
&lt;P&gt;100&lt;/P&gt;
&lt;P&gt;50&lt;/P&gt;
&lt;P&gt;70&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;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; app_summary2;&lt;/P&gt;
&lt;P&gt;set app_summary02;&lt;/P&gt;
&lt;P&gt;format pct percent4.;&lt;/P&gt;
&lt;P&gt;pct=pct2;&lt;/P&gt;
&lt;P&gt;drop pct2;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to format the percent as such however its not formatting correctly&lt;/P&gt;
&lt;P&gt;Desired result&lt;/P&gt;
&lt;P&gt;100%&lt;/P&gt;
&lt;P&gt;50%&lt;/P&gt;
&lt;P&gt;70%&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 00:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328307#M73291</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2017-01-30T00:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage display in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328308#M73292</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;This seems to work for me

HAVE

Up to 40 obs WORK.HAVE total obs=3

Obs            PCT2

 1            0.101
 2            0.201
 3            0.301

WANT

Obs    PCT

 1     10%
 2     20%
 3     30%


SOLUTION

* create some data;
data have;
 do pct2=.101 to .301 by .1;
    output;
 end;
run;quit;

* format new variable;
data want;
set have;
format pct percent.;
pct=pct2;
drop pct2;
run;

* print with format;
proc print data=want;
run;quit;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Jan 2017 00:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328308#M73292</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-01-30T00:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage display in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328310#M73294</link>
      <description>&lt;P&gt;This response points out one of the issues with the percent format. &amp;nbsp;It expects to see values between 0 and 1, not between 0 and 100. &amp;nbsp;So you need to adjust your values accordingly. &amp;nbsp;Values greater than 1 are permitted, so 1.5 prints as 150%.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another issue is that the percent format adds a leading and a trailing blank. &amp;nbsp;That happens because it prints negative numbers in parentheses rather than using a negative sign. &amp;nbsp;So you need to allow enough room in the format width for those characters. &amp;nbsp;If that is less than ideal, you can switch to the&amp;nbsp;PERCENTN format instead of the PERCENT format. &amp;nbsp;No trailing blank is needed, and negative numbers print with a negative sign.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 00:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328310#M73294</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-30T00:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage display in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328326#M73299</link>
      <description>&lt;P&gt;Another option is to create your own format that handles whole numbers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a common question since both PROC TABULATE/FREQ report percents between 0 and 100.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Code tab has the code for a custom format&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/38/001.html" target="_blank"&gt;http://support.sas.com/kb/38/001.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 05:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentage-display-in-datastep/m-p/328326#M73299</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-30T05:26:30Z</dc:date>
    </item>
  </channel>
</rss>

