<?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: Tricky INFILE statement and/or restructuring in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97811#M20611</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stonewaly,&amp;nbsp; While DN can correct me if I'm wrong, I think I figured it out after asking the question.&lt;/P&gt;&lt;P&gt;SAS uses an implicit loop during the datastep.&amp;nbsp; DN hijacked the system created variable, _n_, thus there is nothing that has to be dropped as it is automatically dropped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The records are output each time SAS iterates through one of its implicit loop.&amp;nbsp; Thus for the first record, it goes into its first iteration (when _n_ eq 1) and only inputs one value, then outputs the array.&amp;nbsp; At the end of the non-implicit loop, _n_ has a value of two since it has to increment one beyond the loop setting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus, during the second iteration, it inputs the next 2 values (_n_=1 to 2), then outputs the array and _n_ now has a value of 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus, during the third iteration, it inputs the next 3 values, etc, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you look at the incoming matrix, or just think about it, the first line has one value, the next two, etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 18 Aug 2012 14:04:21 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-08-18T14:04:21Z</dc:date>
    <item>
      <title>Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97805#M20605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For reasons too silly to explain, I must import several correlation matrices into SAS that were originally generated by M&lt;EM&gt;plus&lt;/EM&gt;. The problem is that when M&lt;EM&gt;plus&lt;/EM&gt; outputs such a matrix, it stores only the lower half of the matrix in the following format (first 9 variables only). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;corr.dat&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94232283E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.93041547E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94801541E+00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74084188E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74687603E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.68597923E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.85682659E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.85743307E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.84079052E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74511362E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.79426036E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.78624117E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.75429962E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.72166804E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.84584134E+00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.56886450E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.56152217E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.56380513E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.47751877E+00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.46174713E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.41570092E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54628978E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.55188666E+00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.55358386E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50515092E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50253479E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.39646716E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94309219E+00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.53257041E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54576132E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54605514E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50582361E+00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.49268571E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.37712732E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.90704115E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.95095093E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Two obvious problems here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) the values are in scientific notation.&lt;/P&gt;&lt;P&gt;2) the column structure of the file (i.e. not a square or even lower-half-only matrix structure).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to write code to input the raw correlation data and convert it to an actual correlation matrix in SAS for further analysis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;So far I've been using "find and replace" in &lt;SPAN style="font-family: 'courier new', courier;"&gt;corr.dat&lt;/SPAN&gt; to create a file that looks like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.10000000 , +01 ,&amp;nbsp; 0.94232283 , +00 ,&amp;nbsp; 0.10000000 , +01 ,&amp;nbsp; 0.93041547 , +00 ,&amp;nbsp; 0.94801541 , +00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.10000000 , +01 ,&amp;nbsp; 0.74084188 , +00 ,&amp;nbsp; 0.74687603 , +00 ,&amp;nbsp; 0.68597923 , +00 ,&amp;nbsp; 0.10000000 , +01&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.85682659 , +00 ,&amp;nbsp; 0.85743307 , +00 ,&amp;nbsp; 0.84079052 , +00 ,&amp;nbsp; 0.74511362 , +00 ,&amp;nbsp; 0.10000000 , +01&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.79426036 , +00 ,&amp;nbsp; 0.78624117 , +00 ,&amp;nbsp; 0.75429962 , +00 ,&amp;nbsp; 0.72166804 , +00 ,&amp;nbsp; 0.84584134 , +00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.10000000 , +01 ,&amp;nbsp; 0.56886450 , +00 ,&amp;nbsp; 0.56152217 , +00 ,&amp;nbsp; 0.56380513 , +00 ,&amp;nbsp; 0.47751877 , +00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.46174713 , +00 ,&amp;nbsp; 0.41570092 , +00 ,&amp;nbsp; 0.10000000 , +01 ,&amp;nbsp; 0.54628978 , +00 ,&amp;nbsp; 0.55188666 , +00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.55358386 , +00 ,&amp;nbsp; 0.50515092 , +00 ,&amp;nbsp; 0.50253479 , +00 ,&amp;nbsp; 0.39646716 , +00 ,&amp;nbsp; 0.94309219 , +00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.10000000 , +01 ,&amp;nbsp; 0.53257041 , +00 ,&amp;nbsp; 0.54576132 , +00 ,&amp;nbsp; 0.54605514 , +00 ,&amp;nbsp; 0.50582361 , +00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.49268571 , +00 ,&amp;nbsp; 0.37712732 , +00 ,&amp;nbsp; 0.90704115 , +00 ,&amp;nbsp; 0.95095093 , +00 ,&amp;nbsp; 0.10000000 , +01&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next, I import the data and create a temp dataset, calculating the actual correlations using the exponent values:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;PROC IMPORT OUT= WORK.corr &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAFILE= "c:\temp\CORR.dat" &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=DLM REPLACE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DELIMITER='2C'x; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=NO;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAROW=1; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;set corr;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;array correl (5) var1 var3 var5 var7 var9;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;array expon (5) var2 var4 var6 var8 var10;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;array new (5) new1-new5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;do i = 1 to 5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; new(i) = correl(i)*(10**expon(i));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;drop i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;keep new1-new5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So now my &lt;SPAN style="font-family: 'courier new', courier;"&gt;temp&lt;/SPAN&gt; data looks like this (correct values, wrong structure):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94232283&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.93041547&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94801541 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74084188&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74687603&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.68597923&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.85682659&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.85743307&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.84079052&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74511362&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.79426036&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.78624117&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.75429962&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.72166804&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.84584134&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5688645&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.56152217&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.56380513&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.47751877 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.46174713&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.41570092&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54628978&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.55188666 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.55358386&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50515092&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50253479&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.39646716&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94309219&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.53257041&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54576132&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54605514&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50582361 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; 0.49268571&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.37712732&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.90704115&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.95095093&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;The part I'm stuck on is rearranging the values in the above &lt;SPAN style="font-family: 'courier new', courier;"&gt;temp&lt;/SPAN&gt; dataset to form the lower-triangle correlation matrix I need to move on with the analysis (I already have &lt;SPAN style="font-family: 'courier new', courier;"&gt;IML&lt;/SPAN&gt; code to generate the full square matrix once I obtain the lower half).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;In looking for an answer it seemed like a good idea to export and then re-import the data as below, but the following is clearly too simple (and results in a &lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: LOST CARD&lt;/SPAN&gt; error in the log). Working code would keep the "1" values on the diagonal, creating a new observation beginning with the next data point after encountering a "1" value. The code would then read all subsequent values encountered (over multiple lines of &lt;SPAN style="font-family: 'courier new', courier;"&gt;corr2.dat&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;) as part of the same new observation, up to and including the next "1" value. This process should repeat until the end of the file.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;set temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;file 'c:\temp\corr2.dat';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;put new1-new5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data temp2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;infile 'c:\temp\corr2.dat' flowover;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;input var1-var9;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I have to do this with quite a few different datasets containing different numbers of variables, it would ultimately be fantastic if the code could just handle the original &lt;SPAN style="font-family: 'courier new', courier;"&gt;corr.dat&lt;/SPAN&gt; file (sample pasted at the very top of this post) directly and then do the necessary calculation and restructuring. I am sure there is a way to get SAS to do this, but my INFILE skills are clearly not up to the task. I've also played around with the&amp;nbsp; DLMSTR= option after creating a character delimiter via find-and-replace in &lt;SPAN style="font-family: 'courier new', courier;"&gt;corr2.dat&lt;/SPAN&gt;, to no avail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THANKS for any help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 03:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97805#M20605</guid>
      <dc:creator>stonewaly</dc:creator>
      <dc:date>2012-08-18T03:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97806#M20606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would use the original file and just use a data step.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data corr (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; format _corr 10.8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array corr(9);&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain corr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input _corr @@;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing(of corr(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp; _i+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; corr(1)=_corr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _j=2 to _i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input _corr @@;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; corr(_j)=_corr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94232283E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.93041547E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94801541E+00&lt;/P&gt;&lt;P&gt;0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74084188E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74687603E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.68597923E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&lt;/P&gt;&lt;P&gt;0.85682659E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.85743307E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.84079052E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.74511362E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&lt;/P&gt;&lt;P&gt;0.79426036E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.78624117E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.75429962E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.72166804E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.84584134E+00&lt;/P&gt;&lt;P&gt;0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.56886450E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.56152217E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.56380513E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.47751877E+00&lt;/P&gt;&lt;P&gt;0.46174713E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.41570092E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54628978E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.55188666E+00&lt;/P&gt;&lt;P&gt;0.55358386E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50515092E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50253479E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.39646716E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.94309219E+00&lt;/P&gt;&lt;P&gt;0.10000000E+01&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.53257041E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54576132E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54605514E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50582361E+00&lt;/P&gt;&lt;P&gt;0.49268571E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.37712732E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.90704115E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.95095093E+00&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.10000000E+01&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 04:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97806#M20606</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-18T04:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97807#M20607</link>
      <description>&lt;P&gt;Or simply&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data corr;
   array Corr[9];
   do _n_=1 to _n_;
      input corr[_n_] @@;
      end;
   cards;
0.10000000E+01    0.94232283E+00    0.10000000E+01    0.93041547E+00    0.94801541E+00
0.10000000E+01    0.74084188E+00    0.74687603E+00    0.68597923E+00    0.10000000E+01
0.85682659E+00    0.85743307E+00    0.84079052E+00    0.74511362E+00    0.10000000E+01
0.79426036E+00    0.78624117E+00    0.75429962E+00    0.72166804E+00    0.84584134E+00
0.10000000E+01    0.56886450E+00    0.56152217E+00    0.56380513E+00    0.47751877E+00
0.46174713E+00    0.41570092E+00    0.10000000E+01    0.54628978E+00    0.55188666E+00
0.55358386E+00    0.50515092E+00    0.50253479E+00    0.39646716E+00    0.94309219E+00
0.10000000E+01    0.53257041E+00    0.54576132E+00    0.54605514E+00    0.50582361E+00
0.49268571E+00    0.37712732E+00    0.90704115E+00    0.95095093E+00    0.10000000E+01
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2984i452F0A1878C1D69C/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 13:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97807#M20607</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-05-02T13:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97808#M20608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;respect the master!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 12:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97808#M20608</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2012-08-18T12:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97809#M20609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Peter: Always have!&lt;/P&gt;&lt;P&gt;DN: Nice!&amp;nbsp; But, enlighten me: what triggers the datastep to output the array at the appropriate times?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 13:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97809#M20609</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-18T13:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97810#M20610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow - had no idea it could be that simple!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Thanks&lt;/EM&gt; to data_null_ and Arthur both for your suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For bonus points: Same question as Arthur - How does data_null_'s solution actually work? I get that SAS must already know how to interpret the scientific notation, but how does it know to move to a new observation when it encounters a "1" value? Or, does it &lt;EM&gt;also&lt;/EM&gt; recognize that the values are correlations due to the variable or dataset name (I noticed there's no need to specify TYPE=CORR)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 13:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97810#M20610</guid>
      <dc:creator>stonewaly</dc:creator>
      <dc:date>2012-08-18T13:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97811#M20611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stonewaly,&amp;nbsp; While DN can correct me if I'm wrong, I think I figured it out after asking the question.&lt;/P&gt;&lt;P&gt;SAS uses an implicit loop during the datastep.&amp;nbsp; DN hijacked the system created variable, _n_, thus there is nothing that has to be dropped as it is automatically dropped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The records are output each time SAS iterates through one of its implicit loop.&amp;nbsp; Thus for the first record, it goes into its first iteration (when _n_ eq 1) and only inputs one value, then outputs the array.&amp;nbsp; At the end of the non-implicit loop, _n_ has a value of two since it has to increment one beyond the loop setting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus, during the second iteration, it inputs the next 2 values (_n_=1 to 2), then outputs the array and _n_ now has a value of 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus, during the third iteration, it inputs the next 3 values, etc, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you look at the incoming matrix, or just think about it, the first line has one value, the next two, etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 14:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97811#M20611</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-08-18T14:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97812#M20612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; that "double trailing at sign" holds the input buffer after each column is read (and through the data step iteration) - - so the first line of data satisfies the first two rows of output, and the flowover (infile option default) ensures that the third row takes the remaining two values from row 1 and one from row 2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 14:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97812#M20612</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2012-08-18T14:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Tricky INFILE statement and/or restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97813#M20613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, I've officially learned something : ). Thanks again for all the help and detailed explanation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 17:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tricky-INFILE-statement-and-or-restructuring/m-p/97813#M20613</guid>
      <dc:creator>stonewaly</dc:creator>
      <dc:date>2012-08-18T17:46:01Z</dc:date>
    </item>
  </channel>
</rss>

