<?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: Importing text file with irregularly repeating header in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/494334#M130241</link>
    <description>&lt;P&gt;No that I know more about your problem, I would probably read the data differently.&lt;/P&gt;
&lt;P&gt;I'd try to positively identify each useful record.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data COST;
  retain ABC DRUG PKG TWP ;
  infile datalines truncover; 
  input @;
  if length(_INFILE_);
  if prxmatch('/\d{5}-\d{4}-\d{2}/',_INFILE_) then input @5 ABC $14. @20 DRUG $26. @60 PKG 4.0; *5 then 4 then 2 digits separated by -;
  if prxmatch('/^\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+$/',_INFILE_) then input @60 PKG 4.0; *6 numbers;           
  if left(_INFILE_)=:'TWP' then input @29 TWP dollar8.2  ;                 
  if left(_INFILE_)=:'MAC' then do; input @29 MAC dollar8.2; output; call missing (ABC, DRUG, PKG, TWP); end;                
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Sep 2018 22:48:08 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-09-10T22:48:08Z</dc:date>
    <item>
      <title>Importing text file with irregularly repeating header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/493960#M130084</link>
      <description>&lt;P&gt;Hello Again SAS Friends,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a followup to an earlier question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need to import a .TXT file that has a header that appears irregularly.&amp;nbsp; The header appears at the top of the first page, and then reappears after 87, or 88, 89, 90, or more rows.&amp;nbsp; Sometimes the header is inserted into the data subunits (see below), and splits them into two.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The basic data subunit of interest is either a 6 or 7 rows.&amp;nbsp; The first component of the subunit is a 12 digit number #####-####-##, followed by other variables that are connected to that number.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code to capture the data from the subunits is below.&amp;nbsp; What is not included is code to work around the unwanted header information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is a sample of the .TXT file with the header inserted into inconvenient places to demonstrate the TXT file structure.&amp;nbsp; The actual dataset is ~17000 pages, so is not attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One option tried was to import the entire .TXT file so that there is a single variable and one row for each row of the TXT file.&amp;nbsp; However I could not get all the text (characters and spaces) from one row into a single variable field.&amp;nbsp; If that is possible, then I think SAS character editing can be used to take care of the rest of the import.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or if its possible to somehow remove the header information , that would work too.&amp;nbsp; Should I parse this in another program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;////////////////////////////////////////////////////&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;DATA&lt;/SPAN&gt; Cost&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;infile&lt;/SPAN&gt; datalines truncover&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
&lt;SPAN class="token keyword"&gt;INPUT&lt;/SPAN&gt; 	&lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;5&lt;/SPAN&gt; ABC &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;14&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;20&lt;/SPAN&gt; DRUG &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;26&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;60&lt;/SPAN&gt; PKG &lt;SPAN class="token number"&gt;4.0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;PKG&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; 
    &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;		
          &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;60&lt;/SPAN&gt; 	PKG &lt;SPAN class="token number"&gt;4.0&lt;/SPAN&gt;				
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;  	NN_3 &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;	
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;  	NN_4 &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;	
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;29&lt;/SPAN&gt; 	AWP DOLLAR8&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;			
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;  	NN_6 &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;	 
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;  	NN_7 &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;  
&lt;SPAN class="token keyword"&gt;else&lt;/SPAN&gt; 
    &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; 	
		  &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; 	NN_2 &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; 
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;  	NN_3 &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;	
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;  	NN_4 &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;	
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;29&lt;/SPAN&gt; 	AWP DOLLAR8&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;			
		&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;@&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;  	NN_6 &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;	 
&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;  
&lt;SPAN class="token procnames"&gt;FORMAT&lt;/SPAN&gt;	AWP	Dollar8&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;	&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;	
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;     20000-0000-00  Product6_________________               1            0                    0                0                     0
                    Min Onhand      0         Max Onhand
                                                               0           Lot No            Last Sold                 Manufacture
                    AWP     $0.00             Retail    $0.00              Cost       $0.00  Price Schedule            Drug Expire
                    MAC     $0.00             WAC                          Retail Value      $0.00                     Cost Value        $0.00

    100000-0000-00  Product7_________________ N
                                                            10            0                    0                0    0                0
                    Min Onhand      0         Max Onhand
                                                               0           Lot No            Last Sold                 Manufacture       BAXA CORP.
                    AWP     $158.04           Retail    $0.00              Cost       $0.00  Price Schedule    0       Drug Expire
                    MAC     $0.00             WAC                          Retail Value      $0.00                     Cost Value        $0.00

&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;R&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Sep 2018 21:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/493960#M130084</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-09-09T21:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing text file with irregularly repeating header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/493968#M130087</link>
      <description>&lt;P&gt;The data you provided does not match the input statements. Please always run the code you have pasted before posting.&lt;/P&gt;
&lt;P&gt;Here is a simplified version that does what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data COST;
  infile datalines truncover; 
  link skipheader; input  @5 ABC $14. @20 DRUG $26. @60 PKG 4.0;  
  link skipheader; input @29 TWP dollar8.2  ;                 
  link skipheader; input @29 MAC dollar8.2  ;                 
return;

skipheader:
  do until(NOHEADER);
    input @;
    if left(_infile_) in: ( ' '
                            'Rpt# '         
                            '9/6/2018'
                            '/From'
                            'NDC'
                            'Pkg'
                            'OnHan'
                            'Supplie'
                            'QtySold'
                            'DE PTD'
                            'Equiva') then do; input; NOHEADER=0; end;
    else NOHEADER=1;
  end;
datalines;    
     20000-0000-00  Product6_________________               1            0                    0                0                     0
                    TWP     $3.00             Retail    $0.00              Cost       $0.00  Price Schedule            tops Expire
                    MAC     $4.00             WAC                          Retail Value      $0.00                     Cost Value        $0.00
     100000-0000-00  Product7_________________ N

Rpt# 100                                                       PurchasingSummary Report                                                         Page     1

9/6/2018                                                        Tops Inventory Report                                                           8:36:07 PM

                                             /From SEA: 0 to SEA: 2/Sort By Tops Name ,at location:  Main


                                                       
              NDC                    Tops          Type
                                                                  
                                                              Pkg
                                                                              
                                                                         OnHan
                                                                                                     
                                                                                              Supplie
                                                                                                         QtySold     Order Code
                                                                                                      DE PTD                     Order Qty                   
                                                                                                                                                       Equiva

                    TWP     $158.04           Retail    $0.00              Cost       $0.00  Price Schedule    0       tops Expire
                    MAC     $0.00             WAC                          Retail Value      $0.00                     Cost Value        $0.00
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.COST" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;ABC&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;DRUG&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;PKG&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;TWP&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;MAC&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;20000-0000-00&lt;/TD&gt;
&lt;TD class="l data"&gt;Product6_________________&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;3.00&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;100000-0000-0&lt;/TD&gt;
&lt;TD class="l data"&gt;Product7________________&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;158.04&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Sep 2018 23:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/493968#M130087</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-09T23:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Importing text file with irregularly repeating header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/493972#M130088</link>
      <description>&lt;P&gt;Hi ChrisNZ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wow, Thank you and very cool.&amp;nbsp; Will have to spend some time with this learning what the "Link" statement does.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code with sample data inserted is attached.&amp;nbsp; Sorry for the disconnect in the prior attachment.&lt;/P&gt;&lt;P&gt;There is one aspect that still doesn't work quite right and it's beyond my capabilities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;"Product7_________________" &lt;SPAN&gt;has &lt;U&gt;7 lines&lt;/U&gt; of related data.&amp;nbsp; There is a&amp;nbsp;&lt;/SPAN&gt;letter "N" (@47) just after it&amp;nbsp; then the rows ends.&amp;nbsp; PKG is in the next row , at position&amp;nbsp;@60 PKG 4.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Product6_________________" has 6 lines of related data.&amp;nbsp; Just after &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Product6_________________"&lt;/SPAN&gt;&amp;nbsp;There is no letter, and&amp;nbsp;&lt;/P&gt;&lt;P&gt;PKG is the same row , at position&amp;nbsp;@60 PKG 4.0&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your Output (below), that PKG was not read into the SAS file for&amp;nbsp;&lt;SPAN&gt;"Product7_________________".&amp;nbsp; It does read it in for&amp;nbsp;"Product6_________________"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can that part be updated?&amp;nbsp; Many thanks for your help with this,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;R&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;</description>
      <pubDate>Mon, 10 Sep 2018 00:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/493972#M130088</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-09-10T00:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Importing text file with irregularly repeating header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/493984#M130091</link>
      <description>&lt;P&gt;The key is to check a row before anyinput.&lt;/P&gt;
&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/**********************************************************************************************************/
data COST;
  infile datalines truncover; 
  link skiprows; input @5 ABC $14. @20 DRUG $26. @60 PKG 4.0;   
  if PKG =. then do;
    link skiprows; input @60 PKG 4.0;            
  end; 
  link skiprows; input @29 TWP dollar8.2  ;                 
  link skiprows; input @29 MAC dollar8.2  ;                 
return;

skiprows:
  do until(^SKIPROW);
    input @;                          
    if left(_infile_) in: ( ''
                            'Min'
                            '0 '
                            'Rpt# '         
                            '9/6/2018'
                            '/From'
                            'NDC'
                            'Pkg'
                            'OnHan'
                            'Supplie'
                            'QtySold'
                            'DE PTD'
                            'Equiva') then do; input; SKIPROW=1; end;
    else SKIPROW=0;       
  end;
datalines;    
            
Rpt# 100                                                      Purchasing Summary Report                                                         Page     1

9/6/2018                                                        Tops Inventory Report                                                           8:36:07 PM

                                             /From SEA: 0 to SEA: 2/Sort By Tops Name ,at location:  Main


                                                       
              NDC                    Tops          Type
                                                                  
                                                              Pkg
                                                                              
                                                                         OnHan
                                                                                                     
                                                                                              Supplie
                                                                                                         QtySold     Order Code
                                                                                                      DE PTD                     Order Qty                   
                                                                                                                                                       Equiva



     20000-0000-00  Product6_________________               1            0                    0                0                     0
                    Min Onhand      0         Max Onhand
                                                               0           Lot No            Last Sold                 Manufacture
                    TWP     $0.00             Retail    $0.00              Cost       $0.00  Price Schedule            tops Expire
                    MAC     $0.00             WAC                          Retail Value      $0.00                     Cost Value        $0.00

    100000-0000-00  Product7_________________ N
                                                            10            0                    0                0    0                0
                    Min Onhand      0         Max Onhand
                                                               0           Lot No            Last Sold                 Manufacture       BAXA CORP.
                    TWP     $158.04           Retail    $0.00              Cost       $0.00  Price Schedule    0       tops Expire
                    MAC     $0.00             WAC                          Retail Value      $0.00                     Cost Value        $0.00

     20000-0000-00  Product8_________________               1            0                    0                0                     0
                    Min Onhand      0         Max Onhand
                                                               0           Lot No            Last Sold                 Manufacture
                    TWP     $0.00             Retail    $0.00              Cost       $0.00  Price Schedule            tops Expire
                    MAC     $0.00             WAC                          Retail Value      $0.00                     Cost Value        $0.00

    100000-0000-00  Product9_________________ N
                                                            10            0                    0                0    0                0
                    Min Onhand      0         Max Onhand


Rpt# 100                                                       PurchasingSummary Report                                                         Page     1

9/6/2018                                                        Tops Inventory Report                                                           8:36:07 PM

                                             /From SEA: 0 to SEA: 2/Sort By Tops Name ,at location:  Main


                                                       
              NDC                    Tops          Type
                                                                  
                                                              Pkg
                                                                              
                                                                         OnHan
                                                                                                     
                                                                                              Supplie
                                                                                                         QtySold     Order Code
                                                                                                      DE PTD                     Order Qty                   
                                                                                                                                                       Equiva

                                                               0           Lot No            Last Sold                 Manufacture       BAXA CORP.
                    TWP     $158.04           Retail    $0.00              Cost       $0.00  Price Schedule    0       tops Expire
                    MAC     $0.00             WAC                          Retail Value      $0.00                     Cost Value        $0.00

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.COST" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;ABC&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;DRUG&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;PKG&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;TWP&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;MAC&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;20000-0000-00&lt;/TD&gt;
&lt;TD class="l data"&gt;Product6_________________&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0.00&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;100000-0000-00&lt;/TD&gt;
&lt;TD class="l data"&gt;Product7_________________&lt;/TD&gt;
&lt;TD class="r data"&gt;10&lt;/TD&gt;
&lt;TD class="r data"&gt;158.04&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;20000-0000-00&lt;/TD&gt;
&lt;TD class="l data"&gt;Product8_________________&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0.00&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;100000-0000-00&lt;/TD&gt;
&lt;TD class="l data"&gt;Product9_________________&lt;/TD&gt;
&lt;TD class="r data"&gt;10&lt;/TD&gt;
&lt;TD class="r data"&gt;158.04&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 02:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/493984#M130091</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-10T02:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Importing text file with irregularly repeating header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/494194#M130198</link>
      <description>&lt;P&gt;ChrisNZ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, this is very helpful and I've learned a lot&amp;nbsp;&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 16:41:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/494194#M130198</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-09-10T16:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Importing text file with irregularly repeating header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/494334#M130241</link>
      <description>&lt;P&gt;No that I know more about your problem, I would probably read the data differently.&lt;/P&gt;
&lt;P&gt;I'd try to positively identify each useful record.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data COST;
  retain ABC DRUG PKG TWP ;
  infile datalines truncover; 
  input @;
  if length(_INFILE_);
  if prxmatch('/\d{5}-\d{4}-\d{2}/',_INFILE_) then input @5 ABC $14. @20 DRUG $26. @60 PKG 4.0; *5 then 4 then 2 digits separated by -;
  if prxmatch('/^\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+$/',_INFILE_) then input @60 PKG 4.0; *6 numbers;           
  if left(_INFILE_)=:'TWP' then input @29 TWP dollar8.2  ;                 
  if left(_INFILE_)=:'MAC' then do; input @29 MAC dollar8.2; output; call missing (ABC, DRUG, PKG, TWP); end;                
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Sep 2018 22:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/494334#M130241</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-10T22:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Importing text file with irregularly repeating header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/494430#M130285</link>
      <description>Very interesting , thank you again , will try that out later today and get back to you . Makes perfect sense .</description>
      <pubDate>Tue, 11 Sep 2018 10:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/494430#M130285</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-09-11T10:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Importing text file with irregularly repeating header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/496044#M131082</link>
      <description>&lt;P&gt;Hi Chris,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, many thanks.&lt;/P&gt;&lt;P&gt;This works prefectly, after making one minor change, related to a text pattern that was not present in the TXT sample file I uploaded here.&lt;/P&gt;&lt;P&gt;Changed one line as follows :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch('/^\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+/',_INFILE_) then input @&lt;STRONG&gt;60&lt;/STRONG&gt; PKG_2 &lt;STRONG&gt;4.0&lt;/STRONG&gt;; *begins with 5 numbers, then anything else to end of line ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have now learned how to use PERL characters,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Robert&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>Sun, 16 Sep 2018 15:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-text-file-with-irregularly-repeating-header/m-p/496044#M131082</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-09-16T15:21:41Z</dc:date>
    </item>
  </channel>
</rss>

