<?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 a text file with alternating numbers of rows of related data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493712#M129928</link>
    <description>&lt;P&gt;You may issue many input statements to read a single observation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Cost;
infile datalines truncover; 
INPUT 	@5 ABC $14. @20 DRUG $26. @60 PKG 4.0;
if missing(PKG) then 
    input		
          @60 	PKG 4.0				
		/ @1  	NN_3 $1.	
		/ @1  	NN_4 $1.	
		/ @29 	AWP DOLLAR8.2			
		/ @1  	NN_6 $1.	 
		/ @1  	NN_7 $12;  
else 
    input 	
		  @1 	NN_2 $1. 
		/ @1  	NN_3 $1.	
		/ @1  	NN_4 $1.	
		/ @29 	AWP DOLLAR8.2			
		/ @1  	NN_6 $1.	 
;  
FORMAT	AWP	Dollar8.2	;	
datalines;
     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;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Sep 2018 02:33:41 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-09-08T02:33:41Z</dc:date>
    <item>
      <title>Importing a text file with alternating numbers of rows of related data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493688#M129914</link>
      <description>&lt;P&gt;Hi SAS Friends,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am using SAS ver 9.4 to parse up a large data set where the first variable of each sub data set is a product number, followed by either 6 or 7 additional rows if information related to the product number.&lt;/P&gt;&lt;P&gt;In the 6 row version, row 1 has 124 characters&lt;/P&gt;&lt;P&gt;In the 7 row version, row 1 has only 47 characters and the remaining data drop down to create a new row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached a SAS file with a data step that will import the 6 row data set successfully, and, separately, the 7&lt;SPAN&gt;&amp;nbsp;row data set successfully.&amp;nbsp; However the entire dataset includes 17000 products with the 6 or 7 row subdata sets interspersed randomly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions about how such a large dataset can be imported?&amp;nbsp; How to get SAS to recognize the 6 or 7 row subdata sets and apply the needed code? Or some other strategy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp; very much appreciated,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 23:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493688#M129914</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-09-07T23:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a text file with alternating numbers of rows of related data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493693#M129915</link>
      <description>&lt;P&gt;You have some of&amp;nbsp;the hard work.&lt;/P&gt;
&lt;P&gt;Now for the fun bits.&lt;/P&gt;
&lt;P&gt;Does the same product &lt;STRONG&gt;always&lt;/STRONG&gt; have the same 6 or 7 line layout?&lt;/P&gt;
&lt;P&gt;If so, do you know which?&lt;/P&gt;
&lt;P&gt;If not prepare for more serious coding. Such&amp;nbsp; as do the values of the ABC or PKG give a clue to how many likes are to be read?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 23:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493693#M129915</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-07T23:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a text file with alternating numbers of rows of related data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493712#M129928</link>
      <description>&lt;P&gt;You may issue many input statements to read a single observation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Cost;
infile datalines truncover; 
INPUT 	@5 ABC $14. @20 DRUG $26. @60 PKG 4.0;
if missing(PKG) then 
    input		
          @60 	PKG 4.0				
		/ @1  	NN_3 $1.	
		/ @1  	NN_4 $1.	
		/ @29 	AWP DOLLAR8.2			
		/ @1  	NN_6 $1.	 
		/ @1  	NN_7 $12;  
else 
    input 	
		  @1 	NN_2 $1. 
		/ @1  	NN_3 $1.	
		/ @1  	NN_4 $1.	
		/ @29 	AWP DOLLAR8.2			
		/ @1  	NN_6 $1.	 
;  
FORMAT	AWP	Dollar8.2	;	
datalines;
     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;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Sep 2018 02:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493712#M129928</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-09-08T02:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a text file with alternating numbers of rows of related data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493713#M129929</link>
      <description>&lt;P&gt;So the first row of each series has 124 if its 6 rows and 47 characters in the 7th row?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28361"&gt;@rmacarthur&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi SAS Friends,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the 6 row version, row 1 has 124 characters&lt;/P&gt;
&lt;P&gt;In the 7 row version, row 1 has only 47 characters and the remaining data drop down to create a new row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;R&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If that's so, consider two alternate import statements. Theoretically something like this, assuming I'm interpreting this correctly. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;&lt;BR /&gt;*read line and hold;
input @@;&lt;BR /&gt;*check length of line and execute conditional input;
if length(_infile_) = 147 then do;
input var1 var2
   / var3 var4
...
   / var99 ; *7thline;
end;

else do;
input .....



end;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Sep 2018 02:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493713#M129929</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-08T02:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a text file with alternating numbers of rows of related data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493815#M129999</link>
      <description>&lt;P&gt;Thank you ! Both replies work and both methods will help with importing the dataset.&lt;/P&gt;&lt;P&gt;Much appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Sep 2018 19:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-text-file-with-alternating-numbers-of-rows-of/m-p/493815#M129999</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-09-08T19:14:27Z</dc:date>
    </item>
  </channel>
</rss>

