<?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: leading zeros with Z format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593646#M15554</link>
    <description>&lt;P&gt;apologies for my confusion: Do you want the new variable to be numeric? Also, are you sure you want a new variable and not just format the old one?&lt;/P&gt;</description>
    <pubDate>Thu, 03 Oct 2019 08:55:50 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-10-03T08:55:50Z</dc:date>
    <item>
      <title>leading zeros with Z format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593645#M15553</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having difficulties on leading zeros using Z format. Here is the scenario&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table A&lt;/P&gt;
&lt;P&gt;amount = 100;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what i did is :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;amount = amount * 100;&lt;/P&gt;
&lt;P&gt;amount_new = put(amount, z7.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the output turn out to be expected, eg. 0010000...but, the format is numeric. I know i can convert it to character, but my assumption is by using Z format, the output is in character already.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 08:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593645#M15553</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2019-10-03T08:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: leading zeros with Z format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593646#M15554</link>
      <description>&lt;P&gt;apologies for my confusion: Do you want the new variable to be numeric? Also, are you sure you want a new variable and not just format the old one?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 08:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593646#M15554</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-03T08:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: leading zeros with Z format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593647#M15555</link>
      <description>&lt;P&gt;I want the final output to be in character. meaning, from normal numeric, use Z format to add leading zeros and the output change to character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason why i create the new variable is because to see the changes. But in real production, i will use the same name &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 08:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593647#M15555</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2019-10-03T08:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: leading zeros with Z format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593648#M15556</link>
      <description>&lt;P&gt;What is the logic behind multiplying the amount by 100?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, when you use the PUT Function, the returned value is &lt;STRONG&gt;always&amp;nbsp;&lt;/STRONG&gt;character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, doing this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    amount = 100;
    newAmount=put(Amount, z7.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;makes NewAmount character. Not numeric.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 09:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593648#M15556</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-03T09:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: leading zeros with Z format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593671#M15558</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45239"&gt;@Hhh111&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want the final output to be in character. meaning, from normal numeric, use Z format to add leading zeros and the output change to character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason why i create the new variable is because to see the changes. But in real production, i will use the same name &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
amount = 100;
run;

data want;
set have;
_amount = put(amount*100,z7.);
drop amount;
rename _amount=amount;
run;

proc print data=want noobs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;amount

0010000
&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Oct 2019 11:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/593671#M15558</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-03T11:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: leading zeros with Z format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/594005#M15608</link>
      <description>&lt;P&gt;the actual amount is having decimal&lt;/P&gt;
&lt;P&gt;so for this case, the value is 100.00 (thats the reason why i * with 100). And the original format for this amount is 19.2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;after use PUT function, it does not have leading zeros and the format still numeric. so i guess, somehow the put function and z format is not functioning here. Must be i missed something.&amp;nbsp;&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;</description>
      <pubDate>Fri, 04 Oct 2019 02:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/594005#M15608</guid>
      <dc:creator>Hhh111</dc:creator>
      <dc:date>2019-10-04T02:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: leading zeros with Z format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/594007#M15610</link>
      <description>&lt;P&gt;You use a FORMAT to convert values to character.&amp;nbsp; SAS will use the format attached to a variable when PRINTING the value so that humans can read it. In general if no format is explicitly attached then the BEST format will be used.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create a character variable with the formatted value of a variable you use the PUT() or PUTN() function.&amp;nbsp; Or if the original variable is character and you are using a character format (format name starts with a $) then you could use the PUT() or PUTC() function.&amp;nbsp; You could also use the VVALUE() or VVALUEX() function to get the formatted value of a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you LOOKING at the values where the leading zeros are disappearing?&amp;nbsp; Are you using something like Excel?&amp;nbsp; Excel has a very nasty habit of transforming data when it reads it in from non-Excel binary formats. Like from CSV files.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 02:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/leading-zeros-with-Z-format/m-p/594007#M15610</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-04T02:13:12Z</dc:date>
    </item>
  </channel>
</rss>

