<?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 proc format not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633501#M187926</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have a numeric column named COL1 with values in a dataset . I would like to apply a character format to it by using proc format. but applying the format it's showing wrong values(looks like junk).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If anyone can help me figuring this problem out, please drop a line .&lt;/P&gt;
&lt;P&gt;code i'm using is written below.&lt;/P&gt;
&lt;P&gt;data dummy;input COL1; cards;&lt;/P&gt;
&lt;P&gt;58&lt;BR /&gt;112&lt;BR /&gt;6&lt;BR /&gt;46&lt;BR /&gt;104&lt;BR /&gt;158&lt;BR /&gt;40&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format library=myf.percent;&lt;BR /&gt;value per 58="58/524(11.07%)"&lt;BR /&gt;112="112/524(21.37%)"&lt;BR /&gt;6="6/524(1.15%)"&lt;BR /&gt;46="46/524(8.78%)"&lt;BR /&gt;104="104/524(19.85%)"&lt;BR /&gt;158="158/524(30.15%)"&lt;BR /&gt;40="40/524(7.63%)";&lt;BR /&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;applying format by doing the below step&lt;/P&gt;
&lt;P&gt;data temp2;&lt;BR /&gt;set temp1; options fmtsearch=(myf.percent);&lt;BR /&gt;format col1 percent.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;in the output dataset it shows something like&lt;/P&gt;
&lt;P&gt;6E3% &lt;BR /&gt;1E4% &lt;BR /&gt;600% &lt;BR /&gt;5E3% &lt;BR /&gt;1E4% &lt;BR /&gt;2E4% &lt;BR /&gt;4E3%&lt;/P&gt;</description>
    <pubDate>Fri, 20 Mar 2020 08:44:48 GMT</pubDate>
    <dc:creator>sahoositaram555</dc:creator>
    <dc:date>2020-03-20T08:44:48Z</dc:date>
    <item>
      <title>proc format not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633501#M187926</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have a numeric column named COL1 with values in a dataset . I would like to apply a character format to it by using proc format. but applying the format it's showing wrong values(looks like junk).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If anyone can help me figuring this problem out, please drop a line .&lt;/P&gt;
&lt;P&gt;code i'm using is written below.&lt;/P&gt;
&lt;P&gt;data dummy;input COL1; cards;&lt;/P&gt;
&lt;P&gt;58&lt;BR /&gt;112&lt;BR /&gt;6&lt;BR /&gt;46&lt;BR /&gt;104&lt;BR /&gt;158&lt;BR /&gt;40&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format library=myf.percent;&lt;BR /&gt;value per 58="58/524(11.07%)"&lt;BR /&gt;112="112/524(21.37%)"&lt;BR /&gt;6="6/524(1.15%)"&lt;BR /&gt;46="46/524(8.78%)"&lt;BR /&gt;104="104/524(19.85%)"&lt;BR /&gt;158="158/524(30.15%)"&lt;BR /&gt;40="40/524(7.63%)";&lt;BR /&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;applying format by doing the below step&lt;/P&gt;
&lt;P&gt;data temp2;&lt;BR /&gt;set temp1; options fmtsearch=(myf.percent);&lt;BR /&gt;format col1 percent.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;in the output dataset it shows something like&lt;/P&gt;
&lt;P&gt;6E3% &lt;BR /&gt;1E4% &lt;BR /&gt;600% &lt;BR /&gt;5E3% &lt;BR /&gt;1E4% &lt;BR /&gt;2E4% &lt;BR /&gt;4E3%&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 08:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633501#M187926</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-03-20T08:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc format not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633505#M187927</link>
      <description>&lt;P&gt;There are a few things which don't add-up in the code as posted.&lt;/P&gt;
&lt;P&gt;You define a format with name &lt;EM&gt;per&lt;/EM&gt; but in the data step you're using &lt;EM&gt;percent&lt;/EM&gt;. Also OPTIONS is a global statement. It doesn't belong into a SAS data or Proc step but needs to be outside of it (on its own; global).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input COL1;
  cards;
58
112
6
46
104
158
40
;

proc format ;
  value myformat 
    58="58/524(11.07%)"
    112="112/524(21.37%)"
    6="6/524(1.15%)"
    46="46/524(8.78%)"
    104="104/524(19.85%)"
    158="158/524(30.15%)"
    40="40/524(7.63%)";
run;

proc print data=have;
  format col1 myformat.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Mar 2020 09:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633505#M187927</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-20T09:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc format not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633512#M187930</link>
      <description>&lt;P&gt;The format you actually use is the SAS built-in PERCENT. format, and since the default length is too short for a value of 58 (which translates to 5800 %), it switches to scientific notation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also do not use your example dataset dummy in the final data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using consistent names, the WORK library for formats, the correct format, and proper code formatting, I get this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input COL1;
cards;
58
112
6
46
104
158
40
;

proc format;
value per
  58="58/524(11.07%)"
  112="112/524(21.37%)"
  6="6/524(1.15%)"
  46="46/524(8.78%)"
  104="104/524(19.85%)"
  158="158/524(30.15%)"
  40="40/524(7.63%)"
;
run;

data want;
set have;
format col1 per.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Resulting dataset as displayed:&lt;/P&gt;
&lt;PRE&gt;COL1
58/524(11.07%)	
112/524(21.37%)	
6/524(1.15%)	
46/524(8.78%)	
104/524(19.85%)	
158/524(30.15%)	
40/524(7.63%)&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Mar 2020 09:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633512#M187930</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-20T09:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc format not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633518#M187931</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; looks like junk &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;not unlike your code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take the&amp;nbsp; time to format your code properly (like your respondents did) I promise you'll save time in the long run as many mistakes will be avoided.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 10:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-format-not-working/m-p/633518#M187931</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-20T10:01:43Z</dc:date>
    </item>
  </channel>
</rss>

