<?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: Input function produced missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893958#M353150</link>
    <description>&lt;P&gt;Why are you telling INPUT() to read only the first 8 bytes of B?&amp;nbsp; Are you sure B isn't already a number?&amp;nbsp; If it is then SAS will first convert to a string using BEST12. format and if you only read the first 8 bytes they will all be blanks.&amp;nbsp; But if it is already a number then there is no need for the INPUT() function call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is a string then again why are you only trying to read the first 8 bytes?&amp;nbsp; The normal numeric function can ready 32 bytes.&amp;nbsp; And INPUT() does not care if the string is shorter than the width on the informat.&amp;nbsp; But you might want to remove any &lt;STRONG&gt;leading&lt;/STRONG&gt; spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;b_n=input(left(b),32.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Sep 2023 21:43:05 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-09-12T21:43:05Z</dc:date>
    <item>
      <title>Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893941#M353139</link>
      <description>&lt;P&gt;I have a variable that is all numbers but in character string, because I extracted the numbers from another variable. For example, the variable 'a' is like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;a
1,2
2,3,4&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And I created a new variable 'b' by extracting numbers from 'a', like below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;b
1
2
2
3
4&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But the new 'b' variable is character string, I tried to convert it to numeric by using:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;b_n=input(b,8.);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the b_n is all missing values (bunch of '.'s). What's going on with this situation? Could anyone help me? Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:10:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893941#M353139</guid>
      <dc:creator>SAS-questioner</dc:creator>
      <dc:date>2023-09-12T21:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893942#M353140</link>
      <description>&lt;P&gt;Show your code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: add a trim to remove any additional white space?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;b_n=input(trim(b), 8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893942#M353140</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-09-12T21:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893951#M353145</link>
      <description>&lt;P&gt;I tried, still not working, I used the code like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data long;
	set one;
do i =1 to countw(a, ',');
	b=scan(a,i, ',');
	output;
end;
b_n=input(trim(b), 8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the second time that I encountered this. Last time I remember that I extracted data from excel, and it always produced missing values, so I exported to excel and changed the format and imported back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:28:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893951#M353145</guid>
      <dc:creator>SAS-questioner</dc:creator>
      <dc:date>2023-09-12T21:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893953#M353147</link>
      <description>&lt;P&gt;You really need to show the code of how you get from A to B.&lt;/P&gt;
&lt;P&gt;If the purpose is get the numeric value from A into a new variable then don't bother creating B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   input a $;
datalines;
1,2
2,3,4
;

data want;
   set have;
   do i=1 to countw(a,',');
      bn=input(scan(a,i,','),8.);
      output;
   end;
   drop i;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893953#M353147</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-12T21:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893957#M353149</link>
      <description>Yeah, it works, that's weird that the extra step produced missing values.</description>
      <pubDate>Tue, 12 Sep 2023 21:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893957#M353149</guid>
      <dc:creator>SAS-questioner</dc:creator>
      <dc:date>2023-09-12T21:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893958#M353150</link>
      <description>&lt;P&gt;Why are you telling INPUT() to read only the first 8 bytes of B?&amp;nbsp; Are you sure B isn't already a number?&amp;nbsp; If it is then SAS will first convert to a string using BEST12. format and if you only read the first 8 bytes they will all be blanks.&amp;nbsp; But if it is already a number then there is no need for the INPUT() function call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is a string then again why are you only trying to read the first 8 bytes?&amp;nbsp; The normal numeric function can ready 32 bytes.&amp;nbsp; And INPUT() does not care if the string is shorter than the width on the informat.&amp;nbsp; But you might want to remove any &lt;STRONG&gt;leading&lt;/STRONG&gt; spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;b_n=input(left(b),32.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893958#M353150</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-12T21:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893960#M353151</link>
      <description>Yeah, I am sure the B isn't already a number. I used the proc contents to check. I changed the 8. to 32., and put left in there, it still didn't work.</description>
      <pubDate>Tue, 12 Sep 2023 21:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893960#M353151</guid>
      <dc:creator>SAS-questioner</dc:creator>
      <dc:date>2023-09-12T21:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893962#M353152</link>
      <description>It's because your output STATEMENT is before the b_n is calculated in the code.</description>
      <pubDate>Tue, 12 Sep 2023 21:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893962#M353152</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-09-12T21:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893964#M353154</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data long;
	set one;
do i =1 to countw(a, ',');
	b=scan(a,i, ',');
        b_n=input(trim(b), 8.);
	output;
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Order of operations issue. You are outputting the data before b_n is calculated and only calculating it for the last value.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893964#M353154</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-09-12T21:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893975#M353163</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376504"&gt;@SAS-questioner&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;... stuff deleted ...&lt;BR /&gt;it still didn't work.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Simply telling us that something "doesn't work" ... doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the code and the log, and describe what you got vs what you expected.&amp;nbsp; Help us help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 01:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893975#M353163</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-09-13T01:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Input function produced missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893976#M353164</link>
      <description>Yeah that explains, I tried to put it into different data step and now it works this time.</description>
      <pubDate>Wed, 13 Sep 2023 01:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-produced-missing-values/m-p/893976#M353164</guid>
      <dc:creator>SAS-questioner</dc:creator>
      <dc:date>2023-09-13T01:20:30Z</dc:date>
    </item>
  </channel>
</rss>

