<?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 Extract and Output Words between certain Delimiters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/756752#M238987</link>
    <description>&lt;P&gt;You can modify the ERRORS= option before and after the data step code to eliminate the data errors in the log. Or alternatively clean up the source text file to get rid of the unwanted lines that will generate the data errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options errors=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;BR /&gt;infile "c:\temp\test.txt" firstobs=3 dlm=' ' dsd missover;&lt;BR /&gt;input Start :date11. End :date11. Days :2. CCB :$3.&lt;/P&gt;
&lt;P&gt;Balance :comma20. Rate :percent. Amount :10.;&lt;BR /&gt;format start end date11. balance amount dollar20.2 rate percent10.2;&lt;BR /&gt;if start ne .;/*This cleans up unwanted rows */&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options errors=20;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jul 2021 18:38:23 GMT</pubDate>
    <dc:creator>JOL</dc:creator>
    <dc:date>2021-07-26T18:38:23Z</dc:date>
    <item>
      <title>How to Extract and Output Words between certain Delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/755733#M238537</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Im am trying to extract a txt file to output just certain information but are having trouble&lt;/P&gt;&lt;P&gt;The file is in an email format that I have extracted to txt file. It contains information such as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;today is july 21, the rates are set&amp;nbsp; as&lt;/P&gt;&lt;P&gt;Start End Days CCY Balance Rate Amount&lt;BR /&gt;___________ ___________ ____ ___ __________ _________ ________&lt;/P&gt;&lt;P&gt;&lt;EM&gt;31-Dec-2020 31-Dec-2020 1 USD 819,487.95 3.750000% 85.36&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;information ends&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;today is july 22, the rates are set as&amp;nbsp;&lt;/P&gt;&lt;P&gt;Start End Days CCY Balance Rate Amount&lt;BR /&gt;___________ ___________ ____ ___ __________ _________ ________&lt;/P&gt;&lt;P&gt;&lt;EM&gt;10-Aug-2020 31-Dec-2021 1 USD 10000 3.750000% 100&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;information ends&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i only need the information in italic (after the ------ and before &lt;EM&gt;information ends)&amp;nbsp;&lt;/EM&gt;from this email.&amp;nbsp;&lt;/P&gt;&lt;P&gt;wanting to output so they all come out in different rows like&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;31-Dec-2020 31-Dec-2020 1 USD 819,487.95 3.750000% 85.36&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;10-Aug-2020 31-Dec-2021 1 USD 10000 3.750000% 100&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;any ideas on how to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 19:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/755733#M238537</guid>
      <dc:creator>yuruobei</dc:creator>
      <dc:date>2021-07-21T19:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract and Output Words between certain Delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/755735#M238539</link>
      <description>&lt;P&gt;Provide some of the text, enough to generate at least 3 desired output records, in a TEXT box opened on the forum with the &amp;lt;/&amp;gt; icon above the message window. The message windows reformat text and what you have pasted may not actually look like what you have in the text file, as minimum it has likely inserted some line breaks. The text box will treat your pasted text as just plain text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you expecting variable such as Start End Days CCY Balance Rate Amount in the result or a single&amp;nbsp; line of text?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this may work. There are some assumptions: 1) only one line of values after the line of ____ or what ever, if this is not the case then you need to provide a different example, 2) that the text I copied matches your actual text. It is very likely that simple underscore characters in a bunch like this were replaced by a different character in the message window, 3) that the data is on the line immediately following the under scores&lt;/P&gt;
&lt;PRE&gt;data example;
   infile datalines;
   input @;
   if _infile_="___________ ___________ ____ ___ __________ _________ ________" then do;
      /* free up current line read above*/
      input;
      /* read the values*/
      input  Start :date11. End :Date11. Days CCY :$5. Balance :comma16. Rate :percent10. Amount;
      /* only write to the data set after reading the values*/
      output; 
   end;
   else input;
   format start end date9. rate percent12.6;
datalines;
today is july 21, the rates are set  as
Start End Days CCY Balance Rate Amount
___________ ___________ ____ ___ __________ _________ ________
31-Dec-2020 31-Dec-2020 1 USD 819,487.95 3.750000% 85.36
information ends

today is july 22, the rates are set as 
Start End Days CCY Balance Rate Amount
___________ ___________ ____ ___ __________ _________ ________
10-Aug-2020 31-Dec-2021 1 USD 10000 3.750000% 100
 information ends
;&lt;/PRE&gt;
&lt;P&gt;Your code would have an INFILE pointing to your text file.&lt;/P&gt;
&lt;P&gt;The Input @; reads and holds the current line so it can be examined. _Infile is a character variable holding the current line of data. If there aren't any other ______ you could likely use a much shorter comparison string such as "if _infile_ =: '______' then do; The =: is a "begins with" comparison.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 20:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/755735#M238539</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-21T20:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract and Output Words between certain Delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/755747#M238542</link>
      <description>&lt;P&gt;SAS is a row column based, so even though SAS can read .txt files it will create a row column structure of your source file. You may need to clean up your text file before using the code below.&amp;nbsp; I saved data to a text file that looks&amp;nbsp;like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JOL_0-1626899927022.png" style="width: 430px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61511i44F6C168C1DAF831/image-dimensions/430x389?v=v2" width="430" height="389" role="button" title="JOL_0-1626899927022.png" alt="JOL_0-1626899927022.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use the Modified List Input method to read the text file. See documentation&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_blank"&gt;SAS Help Center: INPUT Statement: List&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;BR /&gt;infile "c:\temp\test.txt" firstobs=3 dlm=' ' dsd missover;&lt;BR /&gt;input Start :date11. End :date11. Days&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;:2. CCB :$3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Balance :comma20. Rate :percent. Amount :10.;&lt;BR /&gt;format start end date11. balance amount dollar20.2 rate percent10.2;&lt;BR /&gt;if start ne .;/*This cleans up unwanted rows */&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Results;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JOL_1-1626900517711.png" style="width: 556px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61512i05460041D7E21B9C/image-dimensions/556x121?v=v2" width="556" height="121" role="button" title="JOL_1-1626900517711.png" alt="JOL_1-1626900517711.png" /&gt;&lt;/span&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 20:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/755747#M238542</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2021-07-21T20:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract and Output Words between certain Delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/755753#M238544</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151645"&gt;@JOL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;SAS is a row column based, so even though SAS can read .txt files it will create a row column structure of your source file. You may need to clean up your text file before using the code below.&amp;nbsp; I saved data to a text file that looks&amp;nbsp;like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JOL_0-1626899927022.png" style="width: 430px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61511i44F6C168C1DAF831/image-dimensions/430x389?v=v2" width="430" height="389" role="button" title="JOL_0-1626899927022.png" alt="JOL_0-1626899927022.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use the Modified List Input method to read the text file. See documentation&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_blank" rel="noopener"&gt;SAS Help Center: INPUT Statement: List&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;BR /&gt;infile "c:\temp\test.txt" firstobs=3 dlm=' ' dsd missover;&lt;BR /&gt;input Start :date11. End :date11. Days&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;:2. CCB :$3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Balance :comma20. Rate :percent. Amount :10.;&lt;BR /&gt;format start end date11. balance amount dollar20.2 rate percent10.2;&lt;BR /&gt;if start ne .;/*This cleans up unwanted rows */&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Results;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JOL_1-1626900517711.png" style="width: 556px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61512i05460041D7E21B9C/image-dimensions/556x121?v=v2" width="556" height="121" role="button" title="JOL_1-1626900517711.png" alt="JOL_1-1626900517711.png" /&gt;&lt;/span&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Really don't like all the "invalid data messages" this is going to generate.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 21:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/755753#M238544</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-21T21:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract and Output Words between certain Delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/756752#M238987</link>
      <description>&lt;P&gt;You can modify the ERRORS= option before and after the data step code to eliminate the data errors in the log. Or alternatively clean up the source text file to get rid of the unwanted lines that will generate the data errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options errors=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;BR /&gt;infile "c:\temp\test.txt" firstobs=3 dlm=' ' dsd missover;&lt;BR /&gt;input Start :date11. End :date11. Days :2. CCB :$3.&lt;/P&gt;
&lt;P&gt;Balance :comma20. Rate :percent. Amount :10.;&lt;BR /&gt;format start end date11. balance amount dollar20.2 rate percent10.2;&lt;BR /&gt;if start ne .;/*This cleans up unwanted rows */&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options errors=20;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jul 2021 18:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Extract-and-Output-Words-between-certain-Delimiters/m-p/756752#M238987</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2021-07-26T18:38:23Z</dc:date>
    </item>
  </channel>
</rss>

