<?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: Two Formats for one variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371238#M88670</link>
    <description>&lt;P&gt;You are asking about formats, but showing a program that doesn't use any formats.&amp;nbsp; All of these are informats within the context of your program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;32.&lt;/P&gt;
&lt;P&gt;dollar32.&lt;/P&gt;
&lt;P&gt;dollar32.2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is it that you are trying to accomplish as the end result?&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2017 12:14:39 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-06-28T12:14:39Z</dc:date>
    <item>
      <title>Two Formats for one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371233#M88669</link>
      <description>&lt;P&gt;I want dollar32. format for non-decimnal value. and dollar32.2 for decimal containing value..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've write below code but its not working as expected. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data ds5;&lt;BR /&gt;input var5 32. ;&lt;BR /&gt;if scan(var5,2,'.') gt 0 then var5=input(var5,dollar32.2);&lt;BR /&gt;else var5=input(var5,dollar32.);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;625355&lt;BR /&gt;856422.54121&lt;BR /&gt;818935.584&lt;BR /&gt;456464.51&lt;BR /&gt;560843.1&lt;BR /&gt;558.55&lt;BR /&gt;58.00&lt;BR /&gt;5&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 12:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371233#M88669</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-06-28T12:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Two Formats for one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371238#M88670</link>
      <description>&lt;P&gt;You are asking about formats, but showing a program that doesn't use any formats.&amp;nbsp; All of these are informats within the context of your program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;32.&lt;/P&gt;
&lt;P&gt;dollar32.&lt;/P&gt;
&lt;P&gt;dollar32.2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is it that you are trying to accomplish as the end result?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 12:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371238#M88670</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-28T12:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Two Formats for one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371249#M88672</link>
      <description>&lt;P&gt;A variable can have no more than 1 format. What you are using here though in your INPUT functions are INformats, which are used to tell SAS how to READ data. not WRITE it.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 12:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371249#M88672</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-28T12:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Two Formats for one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371260#M88674</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; Also, your var5 is a numeric variable. The SCAN function is designed for character variables. So you should be seeing some messages in your log.&lt;BR /&gt;&lt;BR /&gt; It is not clear what you are trying to do. The INPUT function is how you convert a character variable (such as a character string for date or a number with currency) into a number. But you are starting with a number. I don't understand what you're trying to do. Have you even looked at the output from your program without the INPUT???&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9913i675980E341C30EFD/image-size/original?v=1.0&amp;amp;px=-1" alt="not_understand_scan.png" title="not_understand_scan.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not need different formats for storing the internal value of the variable. Do you want different formats for displaying the value of VAR5 in a report? If so, there are other ways to accomplish that. But what you are doing in your program is not clear.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 13:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371260#M88674</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-06-28T13:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Two Formats for one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371267#M88678</link>
      <description>&lt;P&gt;Try PROC FCMP + PROC FORMAT .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.func.t;
function xx(x) $;
length temp $ 40;
  if mod(x,1)=0 then temp=put(x,dollar32.);
   else temp=put(x,dollar32.2);
  return (temp);
endsub;
run;

options cmplib=work.func;
proc format;
value fmt
 low-high=[xx()];
run;


data ds5;
input var5 32. ;
format var5 fmt40.;
datalines;
625355
856422.54121
818935.584
456464.51
560843.1
558.55
58.00
5
;
run;
proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2017 13:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371267#M88678</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-06-28T13:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Two Formats for one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371269#M88679</link>
      <description>&lt;P&gt;I wants value like in want column :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;want&lt;BR /&gt;625355 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$625,355&lt;BR /&gt;856422.5412 $856,422.54&lt;BR /&gt;818935.584 &amp;nbsp; $818,935.58&lt;BR /&gt;456464.51 &amp;nbsp; &amp;nbsp; $456,464.51&lt;BR /&gt;560843.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; $560,843.10&lt;BR /&gt;558.55 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $558.55&lt;BR /&gt;58.00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $58&lt;BR /&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$5&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 13:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371269#M88679</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-06-28T13:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Two Formats for one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371276#M88683</link>
      <description>Thank you so much.... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 28 Jun 2017 13:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Formats-for-one-variable/m-p/371276#M88683</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-06-28T13:12:28Z</dc:date>
    </item>
  </channel>
</rss>

