<?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 input without knowing length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389772#M93473</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I want to convert a character A to numberic B&lt;/P&gt;&lt;P&gt;I use the input() function. But you can only use it if you know the length of A.&lt;/P&gt;&lt;PRE&gt;A = input(B,8.2)&lt;/PRE&gt;&lt;P&gt;But I don't know if it is 8.2 or whatever.&lt;/P&gt;&lt;P&gt;Do you know how I can manage it?&lt;/P&gt;</description>
    <pubDate>Tue, 22 Aug 2017 11:40:35 GMT</pubDate>
    <dc:creator>FP12</dc:creator>
    <dc:date>2017-08-22T11:40:35Z</dc:date>
    <item>
      <title>input without knowing length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389772#M93473</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I want to convert a character A to numberic B&lt;/P&gt;&lt;P&gt;I use the input() function. But you can only use it if you know the length of A.&lt;/P&gt;&lt;PRE&gt;A = input(B,8.2)&lt;/PRE&gt;&lt;P&gt;But I don't know if it is 8.2 or whatever.&lt;/P&gt;&lt;P&gt;Do you know how I can manage it?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 11:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389772#M93473</guid>
      <dc:creator>FP12</dc:creator>
      <dc:date>2017-08-22T11:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: input without knowing length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389776#M93476</link>
      <description>&lt;P&gt;Use the best. format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input b :$32.;
a = input(b,best32.);
format a best32.;
cards;
123456.78
12345678912.22
1.12345678905
3.14159265358979323846
;
run;

proc print data=test noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;b                                                        a

123456.78                                        123456.78
12345678912.22                              12345678912.22
1.12345678905                                1.12345678905
3.14159265358979323846                    3.14159265358979
&lt;/PRE&gt;
&lt;P&gt;Note how the Pi example shows the limits of numeric precision in SAS.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 11:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389776#M93476</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-22T11:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: input without knowing length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389779#M93478</link>
      <description>&lt;P&gt;I would question why you do not know your data, seeing as that is the fundamental basis for programming with? &amp;nbsp;What if it contains non-numerics, or signs/percentages, what format should the output variable have etc.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 12:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389779#M93478</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-22T12:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: input without knowing length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389801#M93483</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a pragmatic approach could be to perform a reconversion check and issue warnings to your log in case of conversion failure.&lt;/P&gt;&lt;P&gt;Something like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;if strip(put(a,best32.)) ne b then put 'W' 'ARNING: conversion issue please check' a= b=;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 13:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389801#M93483</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-08-22T13:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: input without knowing length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389805#M93486</link>
      <description>&lt;P&gt;Another way to verify that the char var has been converted successfully, uses the double ? modifier in the input function. Thanks to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; for provding example data &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input b :$32.;
a = input(b, ?? best32.);
if missing(a) and not missing(b) then put 'WARNING: Failed to convert ' b 'Check obs' _n_= ;
format a best32.;
cards;
123456.78
12345678912.22
1.12345678905
bob
3.14159265358979323846
;
run;

proc print data=test noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Aug 2017 13:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/input-without-knowing-length/m-p/389805#M93486</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-08-22T13:11:32Z</dc:date>
    </item>
  </channel>
</rss>

