<?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: data step input several observations %2F many variables in one record in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237227#M55318</link>
    <description>I don't know why I always forgot that you can process data in the same data step that you import data...</description>
    <pubDate>Tue, 01 Dec 2015 18:15:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-12-01T18:15:39Z</dc:date>
    <item>
      <title>data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237200#M55315</link>
      <description>&lt;P&gt;Dear colleagues&lt;/P&gt;&lt;P&gt;I have a data file with several variables each having multiple observations in one record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataline statement has 'car_type'&amp;nbsp;&amp;nbsp; 'car_color' &amp;nbsp; afterwards three consecutive informations on 'mile'&lt;/P&gt;&lt;P&gt;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; afterwards 'car_dirt' and again three consecutive informations on 'oil'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my strategy was using '@' in order to hold the line and read the multiple observations in do-loops.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output example shows that only the first variable with multiple observations is read properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all the best&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt;input car $ color $&amp;nbsp; @;&lt;BR /&gt;&lt;BR /&gt;do i = 1 to 3;&lt;BR /&gt;&amp;nbsp; input miles @;&lt;BR /&gt;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; input dirty $ @;&lt;BR /&gt;&lt;BR /&gt;do j = 1 to 3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input oil ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;VW green&amp;nbsp;&amp;nbsp; 25 35 28 yes 0.25 0.35 0.28&lt;BR /&gt;bmw yellow 15 25 18 no&amp;nbsp; 0.15 0.25 0.18&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OUTPUT&lt;/P&gt;&lt;P&gt;&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; Beob.&amp;nbsp;&amp;nbsp;&amp;nbsp; car&amp;nbsp;&amp;nbsp;&amp;nbsp; color&amp;nbsp;&amp;nbsp;&amp;nbsp; i&amp;nbsp;&amp;nbsp;&amp;nbsp; miles&amp;nbsp;&amp;nbsp;&amp;nbsp; dirty&amp;nbsp;&amp;nbsp;&amp;nbsp; j&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oil&lt;BR /&gt;&lt;BR /&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; green&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 25&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;BR /&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; green&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 35&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;BR /&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; green&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;BR /&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; green&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.25&lt;BR /&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; green&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 16:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237200#M55315</guid>
      <dc:creator>rjandl</dc:creator>
      <dc:date>2015-12-01T16:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237205#M55316</link>
      <description>&lt;P&gt;I'd consider reading it all as one line and then parsing. Curious to see the methods to read it and separate it at once though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input car $ color $ miles1-miles3 dirty $ oil1-oil3;

datalines;
VW green   25 35 28 yes 0.25 0.35 0.28
bmw yellow 15 25 18 no  0.15 0.25 0.18
;
run;

proc print data=have;
run;

data want;
set have;
array o(3) oil1-oil3;
array m(3) miles1-miles3;

do i=1 to 3;
oil=o(i);
miles=m(i);
output;
end;

drop miles1-miles3 oil1-oil3 i;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Dec 2015 16:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237205#M55316</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-01T16:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237215#M55317</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;I'd consider reading it all as one line and then parsing. Curious to see the methods to read it and separate it at once though &lt;/SPAN&gt;&lt;IMG class="emoticon emoticon-smileyhappy" src="https://kntur85557.i.lithium.com/i/smilies/16x16_smiley-happy.png" border="0" alt="Smiley Happy" title="Smiley Happy" /&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
array m{3} miles1-miles3;
array o{3} oil1-oil3;
input car $ color $ miles1-miles3 dirty $ oil1-oil3;
do i = 1 to 3;
    miles = m{i};
    oil = o{i};
    output;
    end;
drop i miles1-miles3 oil1-oil3;
datalines;
VW green   25 35 28 yes 0.25 0.35 0.28
bmw yellow 15 25 18 no  0.15 0.25 0.18
;

proc print data=want noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Dec 2015 17:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237215#M55317</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-12-01T17:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237227#M55318</link>
      <description>I don't know why I always forgot that you can process data in the same data step that you import data...</description>
      <pubDate>Tue, 01 Dec 2015 18:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237227#M55318</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-01T18:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237241#M55321</link>
      <description>&lt;P&gt;I notice that we don't see many examples where processing tools like SET, MERGE, INPUT and UPDATE are combined in the same data step. That's one thing I'd like to explore though.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 19:32:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237241#M55321</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-12-01T19:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237263#M55322</link>
      <description>&lt;P&gt;Hello Robert,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to your question ("what am I doing wrong?"):&amp;nbsp;After reading CAR, COLOR and the first MILES value (all with the so called "list input") you force SAS to write the current content of the program data vector to dataset NEW (by using an OUTPUT statement). Therefore, DIRTY and OIL (and J, for that matter) have missing values in the first observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, similarly, the second and third MILES value are read and written to the second and third observation, respectively. The values of CAR and COLOR are repeated (without requiring a RETAIN), because we are still in the same, first iteration of the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, DIRTY is read (from the next column). Thanks to the trailing&amp;nbsp;@ line-hold specifiers that have been used so far, the pointer is still located in the first data line, at the appropriate position to read the first OIL value, which is done with the INPUT statement in the first round of the DO J&amp;nbsp;loop. The subsequent OUTPUT statement writes the fourth observation. Again, CAR and COLOR and now also I and MILES "retain" their values. (Please note that variable I had been incremented to 4 at the end of the DO I loop after the last OUTPUT&amp;nbsp;statement in that loop.) Since you forgot (?) the trailing&amp;nbsp;&lt;SPAN&gt;@ after "oil", SAS moves the pointer to the beginning&amp;nbsp;of the next data line.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, the task of the next INPUT statement (in the second round of the DO J loop) is to read another value of the numeric variable OIL. The attempt to store the character value "bmw" in OIL must fail, obviously, and causes&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. a note in the log:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: normal; font-family: 'courier new', courier;"&gt;NOTE: Invalid data for oil in line 17 1-3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;(The line number&amp;nbsp;depends on the session history, but the column range 1-3 indicates where "bmw" is located.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;2. a missing value in variable OIL, which is written (by the OUTPUT statement) to the 5th observation of NEW, together with all the other "retained" values, as we are still in the first iteration of the data step.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, due to the missing trailing&amp;nbsp;&lt;SPAN&gt;@ after "oil", the pointer is moved to the next data line, but there is none, so it is kind of nowhere! This would be no problem if the first iteration of the data step was finished. But, in fact, we haven't executed the third round of the DO J loop yet. This is attempted now, but the INPUT statement (&lt;FONT face="courier new,courier"&gt;input oil;&lt;/FONT&gt;) is bound to fail (the pointer being "nowhere"). SAS documents this situation accurately in the log:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;NOTE: LOST CARD.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+--- &lt;FONT face="arial,helvetica,sans-serif"&gt;...&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;18&amp;nbsp;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;car=VW color=green i=4 miles=28 dirty=yes j=3 oil=. _ERROR_=1 _N_=1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Due to the error condition encountered with the INPUT statement, the data step terminates and the OUTPUT statement (in the third round of the DO J loop) is not executed. That's why we end up with 5 observations and the variable values as explained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt;&amp;nbsp;that it is favorable to read the values first into different variables (using pure list input) and then populate variables MILES and OIL.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, of course, SAS is capable of populating these two variables directly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Using trailing @ line-hold specifiers, OUTPUT statements and @n pointer controls */

data new;
input     car   $
          color $
          miles
      @21 dirty $
          oil @;
output;
input @15 miles
      @30 oil @;
output;
input @18 miles
      @35 oil;
output;
datalines;
VW green   25 35 28 yes 0.25 0.35 0.28
bmw yellow 15 25 18 no  0.15 0.25 0.18
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp;line-hold specifiers keep the pointer in the same data line, until the last value has been read. OUTPUT statements are necessary to create multiple observations of dataset NEW within the same iteration of the data step. A significant drawback of this solution is that we need&amp;nbsp;@n pointer controls to jump to the appropriate positions in the input lines for certain values. This requires that the corresponding values are located in separate columns, which luckily is the case here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To avoid repeating the names of variables MILES and OIL, we could read them in a DO loop, utilizing the fact that their respective column widths are constant:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Using @(expression) pointer controls in a DO loop */

data new;
do _n_=0 to 2;
  input @1                 car   $
                           color $
        @(12+3*mod(_n_,3)) miles
        @21                dirty $
        @(25+5*mod(_n_,3)) oil @;
  output;
end;
datalines;
VW green   25 35 28 yes 0.25 0.35 0.28
bmw yellow 15 25 18 no  0.15 0.25 0.18
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above data step reads the same values of CAR, COLOR and DIRTY three times, but this doesn't matter. The&amp;nbsp;@1 pointer control is required.&amp;nbsp;After the loop has been executed three times for the first data line, the iteration of the data step ends and the pointer moves automatically to the next line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, we could use the double trailing&amp;nbsp;@ line-hold specifier and omit the OUTPUT statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Using a double trailing @ line-hold specifier and no OUTPUT statement */

data new;
retain i 0;
input @1        car   $
                color $
      @(12+3*i) miles
      @21       dirty $
      @(25+5*i) oil @@;
i=mod(i+1,3);
if i=0 then input; /* empty INPUT statement to release the @@ */
drop i;
datalines;
VW green   25 35 28 yes 0.25 0.35 0.28
bmw yellow 15 25 18 no  0.15 0.25 0.18
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here, the observations are written to the output dataset because this happens automatically at the end of each iteration of the data step. The&amp;nbsp;@@ keeps the pointer on the same data line across data step iterations. Therefore, we have to release it "manually" by executing an empty INPUT statement after the last value of a data line has been read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Edit: Only minor&amp;nbsp;changes to the wording.)&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 21:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237263#M55322</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-12-01T21:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237329#M55331</link>
      <description>thanks a lot!</description>
      <pubDate>Wed, 02 Dec 2015 08:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237329#M55331</guid>
      <dc:creator>rjandl</dc:creator>
      <dc:date>2015-12-02T08:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237330#M55332</link>
      <description>thanks</description>
      <pubDate>Wed, 02 Dec 2015 08:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237330#M55332</guid>
      <dc:creator>rjandl</dc:creator>
      <dc:date>2015-12-02T08:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: data step input several observations %2F many variables in one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237331#M55333</link>
      <description>thanks for the detailed response with many insights in the DATA step.</description>
      <pubDate>Wed, 02 Dec 2015 08:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/data-step-input-several-observations-2F-many-variables-in-one/m-p/237331#M55333</guid>
      <dc:creator>rjandl</dc:creator>
      <dc:date>2015-12-02T08:32:10Z</dc:date>
    </item>
  </channel>
</rss>

