<?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: Help with input statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82151#M256675</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response!&amp;nbsp; Your idea did help to avoid getting the delimiter, although I still get a strange result in the case where the CLCODE is missing.&amp;nbsp; I get the sense it may be looking for that length of $1., even in the case where the value is missing.&amp;nbsp; I'd like it to work by just checking before the delimiter, and if it's missing just taking a missing value.&amp;nbsp; In this case, when the clcode above is missing, it inputs the first character of the Agent number (which is actually a character).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Jun 2012 19:22:59 GMT</pubDate>
    <dc:creator>Spacetime</dc:creator>
    <dc:date>2012-06-13T19:22:59Z</dc:date>
    <item>
      <title>Help with input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82149#M256673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my new role, I need to do a lot of inputting flat files pulled from the mainframe.&amp;nbsp; I am having a hard time writing input statements for these, that work in a consistent way.&amp;nbsp; Clearly I am not fully understanding how to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if I have data in a .txt file that looks like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLCODE;AGENT&lt;/P&gt;&lt;P&gt;*;50002&lt;/P&gt;&lt;P&gt;*;50002&lt;/P&gt;&lt;P&gt;;50002&lt;/P&gt;&lt;P&gt;*;50002&lt;/P&gt;&lt;P&gt;*;50002&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Call it test.txt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I try the input step -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;infile test DLM=';' FIRSTOBS=2 LRECL=350 MISSOVER;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;CLCODE $1.&lt;/P&gt;&lt;P&gt;AGENT $5.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not get the expected result.&amp;nbsp; It ignores the delimiter, and instead treats it as part of the string.&amp;nbsp; So when I have a *, I wind up with clcode = * and agent = ;5000.&amp;nbsp; When I do not have a *, I wind up with clcode = ; and agent = 50002.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why will it not work to simply use the DLM as the separator and import each field in the designated informat?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even excel can very quickly and correctly open the test.txt file, with only knowing the delimiter.&amp;nbsp; SAS knows the delimiter and more information and cannot seem to import it correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help, I'm sure I'm missing something basic, but as I said, I have not done a lot of importing flat files in my past life.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 16:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82149#M256673</guid>
      <dc:creator>Spacetime</dc:creator>
      <dc:date>2012-06-13T16:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help with input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82150#M256674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try this..Hope it helps..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;infile&amp;nbsp; 'F:\Community_SAS\funds.txt' dsd dlm= ';' FIRSTOBS=2 LRECL=350 ;&lt;/P&gt;&lt;P&gt;length clcode $1.;&lt;/P&gt;&lt;P&gt;length agent 8.;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;CLCODE $ &lt;/P&gt;&lt;P&gt;AGENT ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 16:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82150#M256674</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-06-13T16:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82151#M256675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response!&amp;nbsp; Your idea did help to avoid getting the delimiter, although I still get a strange result in the case where the CLCODE is missing.&amp;nbsp; I get the sense it may be looking for that length of $1., even in the case where the value is missing.&amp;nbsp; I'd like it to work by just checking before the delimiter, and if it's missing just taking a missing value.&amp;nbsp; In this case, when the clcode above is missing, it inputs the first character of the Agent number (which is actually a character).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 19:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82151#M256675</guid>
      <dc:creator>Spacetime</dc:creator>
      <dc:date>2012-06-13T19:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82152#M256676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Formatted input does not work with DSD DLM a form of list input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;CLCODE $1.&lt;/P&gt;&lt;P&gt;AGENT $5.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should use the : format modifier.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;CLCODE&lt;STRONG&gt; :&lt;/STRONG&gt; $1.&lt;/P&gt;&lt;P&gt;AGENT &lt;STRONG&gt;:&lt;/STRONG&gt; $5.;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 19:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82152#M256676</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-06-13T19:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help with input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82153#M256677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much, that does work.&amp;nbsp; That was the link I was missing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 19:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82153#M256677</guid>
      <dc:creator>Spacetime</dc:creator>
      <dc:date>2012-06-13T19:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82154#M256678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correct me if I'm wrong, but all the solutions so far run into trouble with the line of data that begins with a delimiter.&amp;nbsp; SAS ignores the leading delimiter every time.&amp;nbsp; Fixing the problem is a little harder:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;infile test dlm=';' firstobs=2 dsd lrecl=350;&lt;/P&gt;&lt;P&gt;length clcode $ 1 agent $ 5;&lt;/P&gt;&lt;P&gt;input @;&lt;/P&gt;&lt;P&gt;if _infile_ =: ';'&amp;nbsp; then input agent;&lt;/P&gt;&lt;P&gt;else input clcode agent;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program examines the first character of the incoming data line to see whether or not it begins with a delimiter.&amp;nbsp; It inputs either both variables, or just one, depending on what it finds in that first character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 20:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82154#M256678</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-06-13T20:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help with input statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82155#M256679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, it seems like there are a couple ways to go about it.&amp;nbsp; I have learned a lot about how input works from reading these responses.&amp;nbsp; I made 3 changes to my original code to get it to work perfectly.&amp;nbsp; 2 were to add DSD and TRUNCOVER options (did not have these before).&amp;nbsp; From what I gather the DSD is what makes it recognize my delimiter.&amp;nbsp; The 3rd was to add the colons before the informats&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;CLCODE&lt;STRONG&gt; :&lt;/STRONG&gt; $1.&lt;/P&gt;&lt;P&gt;AGENT &lt;STRONG&gt;:&lt;/STRONG&gt; $5.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I gather, in effect, this makes SAS do the same sort of check your code is performing.&amp;nbsp; It only pays attention to the informat so long as it has not hit the delimiter.&amp;nbsp; So if there is a blank, once it hits the delimiter it moves on, rather than inputting the delimiter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think your example would be a way to get it to work too though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again to all for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 20:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-input-statement/m-p/82155#M256679</guid>
      <dc:creator>Spacetime</dc:creator>
      <dc:date>2012-06-13T20:19:39Z</dc:date>
    </item>
  </channel>
</rss>

