<?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 Reading multiple occurrances of the same fields in SAS - using @ and @@ in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909593#M358749</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have a scenario to read below Input data&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Field1&amp;nbsp; &amp;nbsp;Field2&amp;nbsp; Field3 Field4 Field2 Field3 Field 4 Field2 Field3 Field4 and so on till 78 times&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and write it as,&lt;/P&gt;
&lt;P&gt;Field1 Field2 Field3 Field4&lt;/P&gt;
&lt;P&gt;Field1 Field2 Field3 Field4&lt;/P&gt;
&lt;P&gt;Field1 FIeld2 Field3 Field4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried writing the INPUT statements as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input Field1&amp;nbsp;@;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input Field2 Field3 Field4&amp;nbsp;@@;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it seems to go in a loop and job ended up failing due to space issue with SAS dataset. The input file has less than 100,000 records and sets of Field2, Field3 Field4 is 78. Output records count should be 78*100,000 = 7,800,000&lt;/P&gt;
&lt;P&gt;So am assuming the issue with my code and not with the space issue.&lt;/P&gt;
&lt;P&gt;Could you please clarify?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting below error in the logs&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Insufficient space in file WORK.SASDAT1.DATA. &lt;BR /&gt;ERROR: File WORK.SASDAT1.DATA is damaged. I/O processing did not complete. &lt;BR /&gt;NOTE: 1 record was read from the infile INPFIL1. &lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors. &lt;BR /&gt;NOTE: Due to ERROR(s) above, SAS set option OBS=0, enabling syntax check mode. &lt;BR /&gt;This prevents execution of subsequent data modification statements. &lt;BR /&gt;WARNING: The data set WORK.MAD900WFL may be incomplete. When this step was stopped there were 1712581607 observations and 10&lt;BR /&gt;variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy Holidays&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ram&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 24 Dec 2023 18:00:06 GMT</pubDate>
    <dc:creator>ramkal21</dc:creator>
    <dc:date>2023-12-24T18:00:06Z</dc:date>
    <item>
      <title>Reading multiple occurrances of the same fields in SAS - using @ and @@</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909593#M358749</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have a scenario to read below Input data&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Field1&amp;nbsp; &amp;nbsp;Field2&amp;nbsp; Field3 Field4 Field2 Field3 Field 4 Field2 Field3 Field4 and so on till 78 times&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and write it as,&lt;/P&gt;
&lt;P&gt;Field1 Field2 Field3 Field4&lt;/P&gt;
&lt;P&gt;Field1 Field2 Field3 Field4&lt;/P&gt;
&lt;P&gt;Field1 FIeld2 Field3 Field4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried writing the INPUT statements as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input Field1&amp;nbsp;@;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input Field2 Field3 Field4&amp;nbsp;@@;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it seems to go in a loop and job ended up failing due to space issue with SAS dataset. The input file has less than 100,000 records and sets of Field2, Field3 Field4 is 78. Output records count should be 78*100,000 = 7,800,000&lt;/P&gt;
&lt;P&gt;So am assuming the issue with my code and not with the space issue.&lt;/P&gt;
&lt;P&gt;Could you please clarify?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting below error in the logs&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Insufficient space in file WORK.SASDAT1.DATA. &lt;BR /&gt;ERROR: File WORK.SASDAT1.DATA is damaged. I/O processing did not complete. &lt;BR /&gt;NOTE: 1 record was read from the infile INPFIL1. &lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors. &lt;BR /&gt;NOTE: Due to ERROR(s) above, SAS set option OBS=0, enabling syntax check mode. &lt;BR /&gt;This prevents execution of subsequent data modification statements. &lt;BR /&gt;WARNING: The data set WORK.MAD900WFL may be incomplete. When this step was stopped there were 1712581607 observations and 10&lt;BR /&gt;variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy Holidays&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ram&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Dec 2023 18:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909593#M358749</guid>
      <dc:creator>ramkal21</dc:creator>
      <dc:date>2023-12-24T18:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiple occurrances of the same fields in SAS - using @ and @@</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909596#M358750</link>
      <description>&lt;P&gt;Post the actual SAS log so we can see what code you ran that generated that error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the goal to read from a TEXT file and write to another TEXT file?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'original.txt' flowover ;
  input var1-var78 ;
  file 'newfile.txt' ;
  put (var1-var78) (:best32. :best32. :best32. :best32. / );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You do know that 78 is not a multiple of 4.&lt;/P&gt;
&lt;PRE&gt;211  data _null_;
212    infile in flowover ;
213    input var1-var78 ;
214    file log ;
215    put (var1-var78) (:best32. :best32. :best32. :best32. / );
216  run;

NOTE: The infile IN is:
      (system-specific pathname),
      (system-specific file attributes)

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
33 34 35 36
37 38 39 40
41 42 43 44
45 46 47 48
49 50 51 52
53 54 55 56
57 58 59 60
61 62 63 64
65 66 67 68
69 70 71 72
73 74 75 76
77 78
NOTE: 1 record was read from the infile (system-specific pathname).
      The minimum record length was 224.
      The maximum record length was 224.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Dec 2023 18:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909596#M358750</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-24T18:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiple occurrances of the same fields in SAS - using @ and @@</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909597#M358751</link>
      <description>&lt;P&gt;Do you mean you have 1+78*3 = 235 values on each line of text?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if the goal is to create a DATSET and not another TEXT file then you should be able to generate one observation per repetition using a DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does every line in the source file have all 235 values?&amp;nbsp; If not then you need some type of stopping rule.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'myfile.txt' length=ll column=cc truncover;
  input field1 @;
  do rep=1 by 1 until( cc&amp;gt;ll);
    input field3-filed4 @ ;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Dec 2023 02:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909597#M358751</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-25T02:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiple occurrances of the same fields in SAS - using @ and @@</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909616#M358759</link>
      <description>&lt;P&gt;I presume you mean that each line of your input file has field1, followed by 78 triplets of field2/field3/field4, yes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then something like (say you have only space separated numeric values)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'name of your input file' ;
  input field1 @;
  do _n_=1 to 78;
    input field2 field3 field4 @;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Dec 2023 04:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909616#M358759</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-12-25T04:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiple occurrances of the same fields in SAS - using @ and @@</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909655#M358776</link>
      <description>Your code keeps reading the first line of data.  Nothing in your program allows the software to move to the second line.  While several possible solutions have been mentioned in passing, the right solution would depend on us knowing a bit more about the structure of the incoming data.</description>
      <pubDate>Mon, 25 Dec 2023 18:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909655#M358776</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-12-25T18:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiple occurrances of the same fields in SAS - using @ and @@</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909669#M358787</link>
      <description>&lt;P&gt;Thanks much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;. Yes, this is exactly what i needed. It worked!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2023 03:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-occurrances-of-the-same-fields-in-SAS-using-and/m-p/909669#M358787</guid>
      <dc:creator>ramkal21</dc:creator>
      <dc:date>2023-12-26T03:54:22Z</dc:date>
    </item>
  </channel>
</rss>

