<?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: Variable to include leading 0s in data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672719#M202200</link>
    <description>&lt;P&gt;Thank you!&amp;nbsp; More than one of the options worked.&amp;nbsp; Appreciate the help!&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jul 2020 00:42:55 GMT</pubDate>
    <dc:creator>Bluekeys49</dc:creator>
    <dc:date>2020-07-28T00:42:55Z</dc:date>
    <item>
      <title>Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672433#M202108</link>
      <description>I have a variable SCH_DATE in a data set that is currently numeric with default 8 length. Some of the data reflected in this field looks like the following in month, day, year order:&lt;BR /&gt;&lt;BR /&gt;120968&lt;BR /&gt;52192&lt;BR /&gt;101481&lt;BR /&gt;91565&lt;BR /&gt;&lt;BR /&gt;Ultimately, I want the SCH_DATE to look as follows, to include leading 0s:&lt;BR /&gt;&lt;BR /&gt;120968&lt;BR /&gt;052192&lt;BR /&gt;101481&lt;BR /&gt;091565&lt;BR /&gt;&lt;BR /&gt;How do I make the conversion?</description>
      <pubDate>Mon, 27 Jul 2020 02:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672433#M202108</guid>
      <dc:creator>Bluekeys49</dc:creator>
      <dc:date>2020-07-27T02:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672434#M202109</link>
      <description>&lt;P&gt;If this is just about how a numerical value displays/prints then you can use &lt;A href="https://go.documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p09lpr3kmbh8fen1qepuv6zc1ldd.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;format Zw.d&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;format SCH_DATE z6.;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 02:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672434#M202109</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-27T02:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672435#M202110</link>
      <description>Thank you. I also need it stored permanently as the new value with leading 0s in another SAS data set.&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jul 2020 02:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672435#M202110</guid>
      <dc:creator>Bluekeys49</dc:creator>
      <dc:date>2020-07-27T02:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672437#M202112</link>
      <description>&lt;P&gt;The internal storage of a value in a variable of type Numeric will never have leading zero's - but you can always attach a format permanently to the variable as shown above.&lt;/P&gt;
&lt;P&gt;The other option is to save the digits as a string in a new variable of type Character as shown below:&lt;/P&gt;
&lt;PRE&gt;sch_date_c=put(SCH_DATE, z6.);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 02:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672437#M202112</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-27T02:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672461#M202118</link>
      <description>&lt;P&gt;When values reflect dates, they have to be stored as dates:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length sch_date_new 4;
sch_date_new = input(put(sch_date,z6.),mmddyy6.);
format sch_date_new yymmddd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Because of the sheer stupidity of still using 2-digit years after Y2K, you will have to adjust the YEARCUTOFF option value.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 06:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672461#M202118</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-27T06:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672462#M202119</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294090"&gt;@Bluekeys49&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've totally missed that these values represent dates. Definitely use what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;proposes and convert these numbers into SAS Date values. This then allows you to actually use SAS calendar functions like intnx() and intck().&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 07:04:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672462#M202119</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-27T07:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672719#M202200</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp; More than one of the options worked.&amp;nbsp; Appreciate the help!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 00:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672719#M202200</guid>
      <dc:creator>Bluekeys49</dc:creator>
      <dc:date>2020-07-28T00:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672725#M202205</link>
      <description>&lt;P&gt;You don't have to use the length statement, especially if your data set is compressed, but&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;reply is the only way to go: store a date as a date.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 03:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672725#M202205</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-28T03:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672727#M202207</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294090"&gt;@Bluekeys49&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe you should go for the approach&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;proposed and convert your data to a SAS Date value as this will allow you to actually work with this data as dates - like calculating the number of days between two dates.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 03:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672727#M202207</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-28T03:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672747#M202220</link>
      <description>&lt;P&gt;I prefer to use the length statement because compressing a lot of essentially nothing (hex 00's) still needs more space than not having those bytes in the first place. It's not much, but this old coder hates wasting space and CPU cycles.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 07:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672747#M202220</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-28T07:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672754#M202223</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;I used to do this, but most users would not do it, and I got tired of length-mismatch messages for a small benefit as long as the table is compressed. No right or wrong of course.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 08:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672754#M202223</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-28T08:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672755#M202224</link>
      <description>&lt;P&gt;I do have the benefit of a tightly knitted environment when it comes to data sources. 99% originates from DB/2 or SAP, and is imported by centrally controlled (read: me and two others &amp;lt;g&amp;gt;) processes/programs. We have a macro defined for importing columns with types (char/date/datetime/time/packed decimal/zoned/UUID, even binary), so the length of a date is actually set in one include for all data we have.&lt;/P&gt;
&lt;P&gt;Only when end users import their own data, they can have length issues, but that happens usually only once per user, then they know.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 09:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672755#M202224</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-28T09:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to include leading 0s in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672756#M202225</link>
      <description>It sounds like you have a much tighter environment than where I work. Congratulations:)&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Jul 2020 09:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-to-include-leading-0s-in-data/m-p/672756#M202225</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-28T09:17:10Z</dc:date>
    </item>
  </channel>
</rss>

