<?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: coverting string to numeric in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789777#M40144</link>
    <description>The information I have, is that the original file will use the EBCIDC format and that the variable will be 9 characters long. Then I need to convert it to numeric format like 99.123456&lt;BR /&gt;&lt;BR /&gt;How do we do that?</description>
    <pubDate>Wed, 12 Jan 2022 18:13:30 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2022-01-12T18:13:30Z</dc:date>
    <item>
      <title>coverting string to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789751#M40141</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not very familliar with ebcidic format and I need your help&lt;/P&gt;
&lt;P&gt;we have a zip file that will be unzip on our work environment that we have an old program like below.&amp;nbsp; The new variable will be at position 2250, and will be 9 characters long.&lt;/P&gt;
&lt;P&gt;I need to convert this 9 characters variable into a numeric 9.6 , so I believe 9 number long including the comma and 6 digits after the number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I wonder if I could replace the input line&amp;nbsp;@2250 NEWVARIABLE $EBCDIC9.&lt;/P&gt;
&lt;P&gt;by&amp;nbsp;@2250 NEWVARIABLE&amp;nbsp;S370FZD9.6 to have it converted directly to the good format?&lt;/P&gt;
&lt;P&gt;If not, what should I do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data autoprm;&lt;/P&gt;
&lt;P&gt;length company $1 ...;&lt;BR /&gt;INFILE EBCDIC missover;&lt;BR /&gt;INPUT ...&lt;BR /&gt;@2250 NEWVARIABLE $EBCDIC9. /*S370FZD9.6*/&lt;BR /&gt;;&lt;BR /&gt;FILE ASCII;&lt;BR /&gt;PUT @209 INCEPTIONDATE PD5.&lt;BR /&gt;...&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;... FEW IF STATEMENTS&lt;/P&gt;
&lt;P&gt;OUTPUT autoprm;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 15:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789751#M40141</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2022-01-12T15:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: coverting string to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789755#M40142</link>
      <description>&lt;P&gt;EBCDIC and packed decimal are two different things.&lt;/P&gt;
&lt;P&gt;EBCDIC means the field is text, but the letters just use different codes.&amp;nbsp; So the digit zero is represented by 'F0'X instead of the '30'x used by ASCII.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to if the value stored was 9 digits like '123456789' then that means to actual hex codes for the values stored is 'F0F1F2....' in EBCDIC or '303132....'&amp;nbsp; in ASCII.&amp;nbsp; So first read the values using $EBCDIC to get ASCII version of the string and then use INPUT() with normal informat like 9. to convert the character digits into a number.&amp;nbsp; If the string does not actually include a physical period to represent the decimal place then use informat 9.6 and SAS will divide the number by 10**6 to put the decimal point at the right place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Packed Decimal means the field is binary instead of text.&amp;nbsp; &amp;nbsp;So you can just read the field directly with the appropriate informat.&amp;nbsp; If you do want to read the field into a character string first then use $CHAR informat because you do NOT want to do an EBCDIC to ASCII conversion on the binary codes in that field.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 16:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789755#M40142</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-12T16:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: coverting string to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789777#M40144</link>
      <description>The information I have, is that the original file will use the EBCIDC format and that the variable will be 9 characters long. Then I need to convert it to numeric format like 99.123456&lt;BR /&gt;&lt;BR /&gt;How do we do that?</description>
      <pubDate>Wed, 12 Jan 2022 18:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789777#M40144</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2022-01-12T18:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: coverting string to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789825#M40147</link>
      <description>&lt;P&gt;So if the line original contained the text string '&lt;SPAN&gt;99.123456'&amp;nbsp; then it should have the 9 bytes:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;F9 F9 4B F1 F2 F3 F4 F5 F6&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So read with $EBCDIC9. informat. Then use the INPUT() function to convert that into an actual number.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So if the 9 bytes start in position 235 on the line the code might look something like this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'myfile' ;
  input @235 string $ebcdic9. ;
  number = input(string,9.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jan 2022 21:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789825#M40147</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-12T21:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: coverting string to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789987#M40152</link>
      <description>Hello Tom,&lt;BR /&gt;Based on your above mentioned answer, I have try a little script to help me to understand.  So, value is what I would like to obtain at the end. So,  ebcidic_val=put(value,s370ff9.6), will convert my value to ùùKñòóôõö .  This converted value is what I probably have into myfile &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288234"&gt;@235&lt;/a&gt;.  Then, the input statement &lt;BR /&gt;(newvar1 = input(ebcidic_val,$EBCDIC9. ); convert this strange value into a character. Then we can use another input statement or a format statement to convert it a decimal value, like input(string, 9.6) or format newvar2 9.6&lt;BR /&gt;&lt;BR /&gt;Thank for your help.&lt;BR /&gt;&lt;BR /&gt;data test3;&lt;BR /&gt;format newvar2 9.6 ;&lt;BR /&gt;value=99.123456;&lt;BR /&gt;ebcidic_val=put(value,s370ff9.6);&lt;BR /&gt;newvar1 = input(ebcidic_val,$EBCDIC9. );&lt;BR /&gt;newvar2=newvar1;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 13 Jan 2022 13:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/789987#M40152</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2022-01-13T13:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: coverting string to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/790000#M40153</link>
      <description>&lt;P&gt;Yes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the S370FF informat to convert directly from EBCDIC to numbers without having to first read it as a character string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The meaning of the decimal part on an informat is totally different than the meaning on a format.&amp;nbsp; Do not include the 6 after the decimal point on the informat unless you want values that do not include a period to be divided by 10**6.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
  value1=99.123456;
  string1 = put(value1,9.6);
  ebcdic1 = put(string1,$ebcdic9.);
  ebcdic2 = put(value1,s370ff9.6);

  string2 = input(ebcdic1,$ebcdic9.);

  esame = ebcdic1 = ebcdic2;
  asame = string1 = string2;

  value2= input(string2,9.);
  value3= input(ebcdic1,s370ff9.);

  format string: $quote. ebcdic: $hex. ;
  put (_all_) (=/);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;value1=99.123456
string1="99.123456"
ebcdic1=F9F94BF1F2F3F4F5F6
ebcdic2=F9F94BF1F2F3F4F5F6
string2="99.123456"
esame=1
asame=1
value2=99.123456
value3=99.123456
&lt;/PRE&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 14:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/coverting-string-to-numeric/m-p/790000#M40153</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-13T14:54:52Z</dc:date>
    </item>
  </channel>
</rss>

