<?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: How to convert character variable to numeric with leading zeroes? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/581946#M165449</link>
    <description>&lt;P&gt;You use an INFORMAT to convert text to values and a FORMAT to convert values to text.&lt;/P&gt;
&lt;P&gt;A character INFORMAT creates a character value.&amp;nbsp; A numeric informat creates a numeric value.&amp;nbsp; A character FORMAT displays character values. A numeric format displays numeric values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your program is creating a character variable because you are using a character informat. Use a numeric informat instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data libname.name;
  set libname.dataset;
  tsize=input(tctsize,3.);
  format tsize z3.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note you can use the INPUTN() and INPUTC() functions also.&amp;nbsp; In addition to only working to generate the type of value their names imply they also allow (require) you to pass the informat to use as a value instead of as code.&amp;nbsp; So you could use them where you need to dynamically decide what informat to use.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tsize=inputn(tctsize,'3.');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 17 Aug 2019 18:00:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-08-17T18:00:52Z</dc:date>
    <item>
      <title>How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/581945#M165448</link>
      <description>&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Hi all! Sorry, I’ve already read through a few posts on converting char to num variables, and also documents on formats/informats. However, I can’t figure out why my code isn’t working. I’m hoping someone can help me solve this issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;I want to convert a character variable to a numeric variable. The original variable is &lt;EM&gt;tctsize&lt;/EM&gt;, and has a length of 3 and leading zeroes. I need to keep the zeroes. This variable measures the size of something in mm. The new numeric variable will be called&amp;nbsp;&lt;EM&gt;tsize&lt;/EM&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;I am getting the following &lt;STRONG&gt;error&lt;/STRONG&gt;: “Format $ z3 could not be loaded/found.” The variable’s format changes with my code to $3 but remains as a character variable. I need it to be a numeric variable so I can easily categorize them into groups.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;My dataset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;PERSON_ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;tctsize&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;004&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;2&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 158&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;3&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 016&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;... &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;3,000,000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;016&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;My code&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data libname.name; set libname.dataset;
tsize=input(tctsize,$3.);
format tsize z3.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Thank you!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 17:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/581945#M165448</guid>
      <dc:creator>TL93</dc:creator>
      <dc:date>2019-08-17T17:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/581946#M165449</link>
      <description>&lt;P&gt;You use an INFORMAT to convert text to values and a FORMAT to convert values to text.&lt;/P&gt;
&lt;P&gt;A character INFORMAT creates a character value.&amp;nbsp; A numeric informat creates a numeric value.&amp;nbsp; A character FORMAT displays character values. A numeric format displays numeric values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your program is creating a character variable because you are using a character informat. Use a numeric informat instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data libname.name;
  set libname.dataset;
  tsize=input(tctsize,3.);
  format tsize z3.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note you can use the INPUTN() and INPUTC() functions also.&amp;nbsp; In addition to only working to generate the type of value their names imply they also allow (require) you to pass the informat to use as a value instead of as code.&amp;nbsp; So you could use them where you need to dynamically decide what informat to use.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tsize=inputn(tctsize,'3.');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 18:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/581946#M165449</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-17T18:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/581962#M165457</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;A nice overview - and a good note on INPUTN and INPUTC, lest folks forget they exist. PUTN and PUTC can be added to the roster as well. At times, I find the foursome quite handy at applying informats and formats dynamically, and of course they are indispensable for using with %SYSFUNC. But for all these niceties, a few caveats to bear in mind:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The "dynamic" functions work about 5-7 times slower than their fixed-in/format counterparts.&lt;/LI&gt;
&lt;LI&gt;R=PUTN(N,F) returns R as $200 if R is not sized beforehand.&lt;/LI&gt;
&lt;LI&gt;If R in R=PUTC(C,F) is not pre-sized, its length is determined by that of C irrespective of the content of F.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 19:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/581962#M165457</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-17T19:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582137#M165518</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your response. I was under the impression that " $3. " is telling SAS that I am inputting a variable with a character informat, and the variable has meaningful leading zeroes (e.g. 004). And that " z3. " is telling SAS to format this variable as a numeric variable and keep the leading zeroes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to run the code you suggested, removing the dollar sign:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data libname.name;
  set libname.dataset;
  tsize=input(tctsize,3.);
  format tsize z3.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and although the new variable&amp;nbsp;&lt;EM&gt;tsize&lt;/EM&gt; is now a numeric variable, all the zeroes in front of the values were dropped. So if&amp;nbsp;&lt;EM&gt;tctsize=004&lt;/EM&gt; then&amp;nbsp;&lt;EM&gt;tsize=4&lt;/EM&gt;. Following this example, I'd want&amp;nbsp;&lt;EM&gt;tsize&lt;/EM&gt;&amp;nbsp;to be a numeric variable that&amp;nbsp;&lt;EM&gt;=004.&amp;nbsp;&lt;/EM&gt;Do you have any insight on why that might be the case?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 15:43:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582137#M165518</guid>
      <dc:creator>TL93</dc:creator>
      <dc:date>2019-08-19T15:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582147#M165522</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/227543"&gt;@TL93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your response. I was under the impression that " $3. " is telling SAS that I am inputting a variable with a character informat, and the variable has meaningful leading zeroes (e.g. 004). And that " z3. " is telling SAS to format this variable as a numeric variable and keep the leading zeroes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to run the code you suggested, removing the dollar sign:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data libname.name;
  set libname.dataset;
  tsize=input(tctsize,3.);
  format tsize z3.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and although the new variable&amp;nbsp;&lt;EM&gt;tsize&lt;/EM&gt; is now a numeric variable, all the zeroes in front of the values were dropped. So if&amp;nbsp;&lt;EM&gt;tctsize=004&lt;/EM&gt; then&amp;nbsp;&lt;EM&gt;tsize=4&lt;/EM&gt;. Following this example, I'd want&amp;nbsp;&lt;EM&gt;tsize&lt;/EM&gt;&amp;nbsp;to be a numeric variable that&amp;nbsp;&lt;EM&gt;=004.&amp;nbsp;&lt;/EM&gt;Do you have any insight on why that might be the case?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A number does not have leading zeros (or alternatively it has an infinite number of leading zeros).&amp;nbsp; There is no difference between any of these ways of expressing the value : 4, 04, 004, 0004, 4.00, 4E0, ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are not seeing the leading zeros when you print the data then the method you are using is not using the format that you attached to the variable.&amp;nbsp; Or you have viewed the output with a program like Excel that will suppress the leading zeros in the text because it thinks the value is a number.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 15:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582147#M165522</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-19T15:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582161#M165526</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/227543"&gt;@TL93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your response. I was under the impression that " $3. " is telling SAS that I am inputting a variable with a character informat, and the variable has meaningful leading zeroes (e.g. 004). And that " z3. " is telling SAS to format this variable as a numeric variable and keep the leading zeroes.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS has two types of variables.&amp;nbsp; Fixed length character strings and floating point numbers. The FORMAT attached to a variable is just an attribute that tells SAS which format to use by default when displaying the value of the variable.&amp;nbsp; A FORMAT is special instructions for how to convert the value into text.&amp;nbsp; An INFORMAT is special instructions for how to convert a text string into a value. If you use $3 informat you are telling SAS to read the first three bytes and store them without conversion. (Except on an IBM mainframe where it will convert an EBCDIC string into its corresponding ASCII string.)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582161#M165526</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-19T16:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582167#M165530</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the explanation. It was very valuable information. I'm happy to say that you're right and your suggestions ended up working. I was able to get the data I wanted by dropping the ' $ ' and converting the text string into a value. Cheers!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582167#M165530</guid>
      <dc:creator>TL93</dc:creator>
      <dc:date>2019-08-19T16:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582184#M165543</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"If you use $3 informat you are telling SAS to read the first three bytes and store them without conversion."&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Without conversion" would be the case with $CHARw. By contrast, $w. does at least some conversion: (a) trims the leading blanks and left-aligns the value, (b) converts a single period to a blank if the field has only blanks and one single period, i.e. treats the period as a missing value.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;Except on an IBM mainframe where it will convert an EBCDIC string into its corresponding ASCII string."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It's an interesting news to me. Whenever I worked on the big iron, $w. never changed the encoding, and EBCDIC always remained EBCDIC. The $ACSIIw. &lt;EM&gt;informat&lt;/EM&gt; would convert ASCII data to EBCDIC; and the only thing that would convert EBCDIC to ACSII would be the $ASCIIw. &lt;EM&gt;format&lt;/EM&gt;. If nowadays the $w. informat on the mainframes behaves as you say,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I wonder when the change occurred ... and what for.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Kind regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Paul D.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 17:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582184#M165543</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-19T17:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582195#M165552</link>
      <description>&lt;P&gt;Been 30 years since I used IBM mainframes. But when reading from text files the $ informat/formats converted between the EBCDIC characters in the files and the ASCII characters in the SAS variables. Perhaps the method was similar to how transcoding between UTF-8 and WLATIN1 is done now. If you want to actually read/write ASCII code you needed to use the $ASCII informat or the $ASCII format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So on a Mainframe wrting with $EBCDIC is the same was writing with $.&amp;nbsp; And on an ASCII based system writing with $ASCII is the same writing with $.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 17:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582195#M165552</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-19T17:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582256#M165584</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;My mainframe exposure is quite a bit more recent.&lt;/P&gt;
&lt;P&gt;Frankly, I'm not sure how to interpret your expression "&lt;SPAN&gt;$ informat/formats converted between the EBCDIC characters in the files and the ASCII characters in the SAS variables". This is because in my experience, any character read from a text file under z/OS into a SAS character variable using $CHARw. (identical to $EBCDICw. under this OS) keeps its EBCDIC encoding. Same with $w., except for the left justification and period conversion.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;The only situation I can fancy when an &lt;EM&gt;in&lt;/EM&gt;format converts a text field from EBCDIC to ASCII is when a mainframe text file is ported to an ASCII system &lt;EM&gt;as binary&lt;/EM&gt; and then the field is read under ASCII using the $EBCDICw. informat.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 20:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582256#M165584</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-19T20:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582258#M165585</link>
      <description>&lt;P&gt;Character values in SAS datasets are stored in ASCII not EBCDIC. At least they were in SAS version 5. Use the $HEX format to check for yourself.&amp;nbsp; It makes collating characters much easier since 'B' is one larger then 'A' etc onto 'Z' in ASCII, but in EBCDIC the codes for letters are all over the place.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582258#M165585</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-19T21:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582274#M165590</link>
      <description>&lt;P&gt;Yes, the $ informat will left align the results. Essentially moving any leading spaces to the end.&amp;nbsp; Whereas the $CHAR informat does not. It will "preserve" the leading spaces.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582274#M165590</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-19T21:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582277#M165591</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;I'm not sure about V5, but can aver beyond a shadow of a doubt that currently, if under z/OS (MVS, OS/390, etc.) you read a character from a text file into a SAS data set character variable using $w., it will have the same hex representation in the SAS data set as it has in the text file. If it were auto-converted to ASCII, you'd see, for example, the character "9" in the text file as "F9"x (EBCDIC) and the same in the SAS variable as "39"x (ASCII). This is &lt;EM&gt;not&lt;/EM&gt; the case, or at least not what I see looking at the same value using the ISPF hex mode and the $HEX2. format in SAS; instead, both appear as "F9" (and I highly doubt that $HEXw. on the mainframe, when applied to a SAS variable, converts back from ASCII to EBCDIC - it it were the case, I'd find it extremely bizarre).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you're saying that character values are stored in SAS data sets in ASCII &lt;EM&gt;internally&lt;/EM&gt; regardless of the system encoding? If so, I can neither deny nor confirm it (though if it indeed were true, I'd find it equally bizarre).&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582277#M165591</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-19T21:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582281#M165592</link>
      <description>&lt;P&gt;Perhaps the implementation of encoding support changed the behavior.&amp;nbsp; If you check the SAS 9.2 documentation on-line if definitely says that $EBCDIC and $CHAR are the same on main frames and $ASCII and $CHAR are the same on ASCII based hosts.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 22:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582281#M165592</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-19T22:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character variable to numeric with leading zeroes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582282#M165593</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Plus, if the field consists of a &lt;EM&gt;single&lt;/EM&gt; period (the rest of the characters being blank), $w. will convert it to a space, while $CHARw. will not:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;                  
  c1 = input (" . ", $3.) ;    
  c2 = input (" ..", $3.) ;    
  c3 = input (" . ", $char3.) ;
  put (c:) (=$hex6./) ;         
run ;                          
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result (20=blank, 2E=period):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;c1=202020
c2=2E2E20
c3=202E20
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 22:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-with-leading-zeroes/m-p/582282#M165593</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-19T22:11:09Z</dc:date>
    </item>
  </channel>
</rss>

