<?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: Formatting Data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272138#M54132</link>
    <description>&lt;P&gt;You cannot change the format of the variable in DATA step. &amp;nbsp;Your variable is text in both HAVE&amp;nbsp;and OUT. &amp;nbsp;Also, z3. is not useful as an informat. &amp;nbsp;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt; a='83.00000000';&lt;BR /&gt;run;&lt;BR /&gt;data out;&lt;BR /&gt; set have;&lt;BR /&gt; b=input(a,3.);&lt;BR /&gt; format b z3.;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Fri, 20 May 2016 20:29:25 GMT</pubDate>
    <dc:creator>Haris</dc:creator>
    <dc:date>2016-05-20T20:29:25Z</dc:date>
    <item>
      <title>Formatting Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272123#M54129</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I have a 11 caracter (Length 11, Format $11., Informat $11.) long text which is &amp;nbsp;'83.0000000'.&lt;/P&gt;
&lt;P&gt;I want to convert it as 083 (character type). Can someone help please.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;83.0000000 should be 083&lt;/P&gt;
&lt;P&gt;95.0000000&amp;nbsp;&lt;SPAN&gt;should be 095&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;100.000000 should be 100&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wrote the following code, but it still doesn't help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA Have;&lt;BR /&gt;A='83.00000000';&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;DATA Out;&lt;BR /&gt;SET Have;&lt;BR /&gt;A=INPUT(A,z3.);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 20:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272123#M54129</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-20T20:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272132#M54130</link>
      <description>&lt;P&gt;A = substr(a,1,index(a,'.')-1);&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 20:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272132#M54130</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-20T20:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272138#M54132</link>
      <description>&lt;P&gt;You cannot change the format of the variable in DATA step. &amp;nbsp;Your variable is text in both HAVE&amp;nbsp;and OUT. &amp;nbsp;Also, z3. is not useful as an informat. &amp;nbsp;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt; a='83.00000000';&lt;BR /&gt;run;&lt;BR /&gt;data out;&lt;BR /&gt; set have;&lt;BR /&gt; b=input(a,3.);&lt;BR /&gt; format b z3.;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 20:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272138#M54132</guid>
      <dc:creator>Haris</dc:creator>
      <dc:date>2016-05-20T20:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272139#M54133</link>
      <description>Hi ballardw,&lt;BR /&gt;Your code returns 83, 93, 100. and the length is still 11, but I want it like 083, 093, 100. Thanks,</description>
      <pubDate>Fri, 20 May 2016 20:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272139#M54133</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-20T20:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272159#M54135</link>
      <description>Thanks Haris,&lt;BR /&gt;It works, but the length is still 8, how can i minimize it to 3?</description>
      <pubDate>Fri, 20 May 2016 20:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272159#M54135</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-20T20:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272162#M54136</link>
      <description>&lt;P&gt;Don't know why the length would matter but here it is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data out; length a 3.;&lt;BR /&gt;&amp;nbsp;set have(rename=(a=OldA));&amp;nbsp;&lt;BR /&gt;&amp;nbsp;a=input(OldA,3.);&lt;BR /&gt;&amp;nbsp;format a z3.;&lt;BR /&gt;&amp;nbsp;drop OldA;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I re-wrote it a bit to preserve your variable name A using RENAME in the SET statement.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 20:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272162#M54136</guid>
      <dc:creator>Haris</dc:creator>
      <dc:date>2016-05-20T20:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272252#M54163</link>
      <description>&lt;P&gt;SAS always stores numbers as floating point. &amp;nbsp;So you can reduce the storage from 8 to 3 as long as you only have small integers.&lt;/P&gt;
&lt;P&gt;But is sounds like you want to convert your 11 character string to a 3 character string. &amp;nbsp;You can use a number as an intermediate step.&lt;/P&gt;
&lt;P&gt;So if your original variable is named HAVE this will create a new variable named WANT that is length $3 and has the leading zeros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want = put( input(have,11.) , Z3.) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2016 16:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-Data/m-p/272252#M54163</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-21T16:36:44Z</dc:date>
    </item>
  </channel>
</rss>

