<?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: Adding Trailing Zeros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780441#M248687</link>
    <description>Yes, and it reads those as being assigned to that state. The first two numbers have to be 29 for my dataset. if it reads 00 then it will return an error because that is an invalid FIPS code.</description>
    <pubDate>Tue, 16 Nov 2021 14:28:02 GMT</pubDate>
    <dc:creator>DanielQuay</dc:creator>
    <dc:date>2021-11-16T14:28:02Z</dc:date>
    <item>
      <title>Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779647#M248353</link>
      <description>&lt;P&gt;&amp;nbsp;I have a number of ID variables.&amp;nbsp; They are ten characters long but I need them to be thirteen characters long to match the data dictionary.&lt;/P&gt;&lt;P&gt;The suggestion was that I simply add three trailing zeros to each case but I can't seem to figure out how to do that in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 20:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779647#M248353</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2021-11-10T20:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779650#M248355</link>
      <description>Usual recommendation is to add leading zeros, not trailing zeros. Hard to know which is useful that way. &lt;BR /&gt;&lt;BR /&gt;There are many ways to do this but if all are 10 this is easy. Assuming this is character vairable:&lt;BR /&gt;&lt;BR /&gt;if length(variable) = 10 then ID_new = catt('000', variable);&lt;BR /&gt;&lt;BR /&gt;If you really want it trailing, reverse the order of the arguments in the function. &lt;BR /&gt;&lt;BR /&gt;If your variable is numeric you can use the Z13 format to accomplish this.</description>
      <pubDate>Wed, 10 Nov 2021 20:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779650#M248355</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T20:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779654#M248357</link>
      <description>&lt;P&gt;So the data is numeric, but the z format option doesn't appear to be doing it.&amp;nbsp; And for this specific request it needs to be trailing zero's.&amp;nbsp; The system it's going into can't handle leading zeros.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I'm trying:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;ID2 = catt(ID, z15.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 21:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779654#M248357</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2021-11-10T21:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779660#M248360</link>
      <description>ID2_trailing = catt(ID, '000');&lt;BR /&gt;&lt;BR /&gt;ID2_leading = put(ID, z13.);&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Nov 2021 22:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779660#M248360</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T22:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779681#M248370</link>
      <description>&lt;P&gt;It sounds like you may need to confirm that the "other data" is actually numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your values are supposed to be numeric they should be in the correct range numerically. The fact that you need trailing zeroes means that you values are 10, 100 or 1000 times too small. ie a value if a value of 1 needs three zeroes then the numeric value needs to be 1000. Which would lead me back to how did you read the original value such that it missed 3 significant (or possibly more?) digits when read. This looks like a time to investigate the cause, likely at the read step, and address it there. Then no "fixing" would needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 23:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779681#M248370</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-10T23:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779685#M248371</link>
      <description>&lt;P&gt;So you have numeric values and you want to add three extra zeros?&amp;nbsp; Just multiply by 1,000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the request does not really make much sense, something seems missing in your explanation of the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Numbers do not have a "number of characters" unless you are writing them into text.&amp;nbsp; If you want to print the values into a text file and have them always use 10 character positions then just print them with the 10. (or Z10. ) format.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2021 01:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/779685#M248371</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-11T01:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780431#M248685</link>
      <description>&lt;P&gt;Sorry, sick kid been away from the computer for a bit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway okay I can break down the why of this request.&lt;/P&gt;&lt;P&gt;I was handed a raw dataset with a unique ID variable that was structured to the original request.&lt;/P&gt;&lt;P&gt;This has changed and they now need the unique ID variable to be longer (numeric data).&lt;/P&gt;&lt;P&gt;The data structure cannot have leading zero's because it requires the first two to be a state FIPS code identifier.&lt;/P&gt;&lt;P&gt;As such I need to add extra characters to the end of the unique ID from the raw dataset, but they still want it to be a numeric data type.&lt;/P&gt;&lt;P&gt;I get that it's not the usual way to do things, but it's what I got handed.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 14:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780431#M248685</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2021-11-16T14:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780440#M248686</link>
      <description>&lt;P&gt;"The data structure cannot have leading zero's because it requires the first two to be a state FIPS code identifier."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Federal_Information_Processing_Standard_state_code" target="_blank" rel="noopener"&gt;https://en.wikipedia.org/wiki/Federal_Information_Processing_Standard_state_code&lt;/A&gt;, several state codes (e.g. Alabama - 01) start with a zero.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 14:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780440#M248686</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-16T14:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780441#M248687</link>
      <description>Yes, and it reads those as being assigned to that state. The first two numbers have to be 29 for my dataset. if it reads 00 then it will return an error because that is an invalid FIPS code.</description>
      <pubDate>Tue, 16 Nov 2021 14:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780441#M248687</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2021-11-16T14:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780447#M248688</link>
      <description>&lt;P&gt;So you need to multiply those values that are below a certain threshold:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input code;
format code 13.;
datalines;
2934567890
2912345678000
;

data want;
set have;
if code lt 10000000000
then code = code * 1000;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Nov 2021 14:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780447#M248688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-16T14:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780449#M248689</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Yes, and it reads those as being assigned to that state. The first two numbers have to be 29 for my dataset. if it reads 00 then it will return an error because that is an invalid FIPS code.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perhaps if you can explain more about what you are doing then an easier, clearer way forward can be found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you using this data with other SAS code?&amp;nbsp; Do you have access to the source code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you passing the data from your SAS dataset to some other system to use?&amp;nbsp; How are you transferring the data? Are you writing a text file for the other system to read?&amp;nbsp; What is the format required for that text file?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you pushing data into an external database?&amp;nbsp; How are the fields defined in that external database?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 14:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780449#M248689</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-16T14:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780455#M248691</link>
      <description>&lt;P&gt;THis got it, but I had to add a format for it to print properly to the CSV txt file I had to send them.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 14:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780455#M248691</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2021-11-16T14:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Trailing Zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780458#M248693</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;THis got it, but I had to add a format for it to print properly to the CSV txt file I had to send them.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now wait, all this for a &lt;STRONG&gt;TEXT&lt;/STRONG&gt; file???&lt;/P&gt;
&lt;P&gt;Then there is absolutely no need to handle this as numbers in SAS.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 14:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Trailing-Zeros/m-p/780458#M248693</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-16T14:49:44Z</dc:date>
    </item>
  </channel>
</rss>

