<?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 Using more than one Input statement to combine data lines in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980392#M43586</link>
    <description>&lt;P&gt;Hi - My input potentially has multiple lines that make up the data line. I'm trying to read those and format into a single output line without much success.&lt;/P&gt;&lt;P&gt;The lines starting with JOB= would be associated with the preceding line. There may be no JOB= lines, or there may be multiple lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;                                                         
   infile cards missover;                                          
   input #01 name         $ 01-08 @;                               
   if substr(name, 1, 4) ne 'JOB=' then do;                        
   input #02 lastrun      $ 63-66                                  
   else do;                                                        
   input #02 rqmt         $ 05-12                                  
             leadtm       $ 58-59 ;                                
    end;                                                           
   cards;                                                          
FREDFRED 004 FREDFRED FMS      001 ALL  *NONE*  YES   000 000 1732 
BARNEY   004 BARNEY   ABZ      001 ALL  *NONE*  YES   000 000 1341 
JOB=JOB00001        SCHID=000   VRSN=09063/1602   LEADTM=08        
JOB=JOB00043        SCHID=000   VRSN=94322/1613                    
WILMA    004 WILMA    TRE      001 ALL  *NONE*  YES   000 000 0000 
JOB=STEP9999        SCHID=000   VRSN=07263/0650   LEADTM=99        
BETTY    004 BETTY    KIL      001 ALL  *NONE*  YES   000 000 2351 
;           
   run;     
            
proc print; 
   run;     &lt;/PRE&gt;&lt;P&gt;This is what I would like to see:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Name		lastrun		rqmt		leadtm	
FREDFRED	1732	
BARNEY	        1341		JOB0001 	08
BARNEY	        1341		JOB00043	
WILMA		0000		STEP9999	99
BETTY		2351&lt;/PRE&gt;&lt;P&gt;I can't seem to figure out how to handle those entries consisting of multiple lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any assistance. Thanks.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Dec 2025 19:31:52 GMT</pubDate>
    <dc:creator>serge68</dc:creator>
    <dc:date>2025-12-08T19:31:52Z</dc:date>
    <item>
      <title>Using more than one Input statement to combine data lines</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980392#M43586</link>
      <description>&lt;P&gt;Hi - My input potentially has multiple lines that make up the data line. I'm trying to read those and format into a single output line without much success.&lt;/P&gt;&lt;P&gt;The lines starting with JOB= would be associated with the preceding line. There may be no JOB= lines, or there may be multiple lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;                                                         
   infile cards missover;                                          
   input #01 name         $ 01-08 @;                               
   if substr(name, 1, 4) ne 'JOB=' then do;                        
   input #02 lastrun      $ 63-66                                  
   else do;                                                        
   input #02 rqmt         $ 05-12                                  
             leadtm       $ 58-59 ;                                
    end;                                                           
   cards;                                                          
FREDFRED 004 FREDFRED FMS      001 ALL  *NONE*  YES   000 000 1732 
BARNEY   004 BARNEY   ABZ      001 ALL  *NONE*  YES   000 000 1341 
JOB=JOB00001        SCHID=000   VRSN=09063/1602   LEADTM=08        
JOB=JOB00043        SCHID=000   VRSN=94322/1613                    
WILMA    004 WILMA    TRE      001 ALL  *NONE*  YES   000 000 0000 
JOB=STEP9999        SCHID=000   VRSN=07263/0650   LEADTM=99        
BETTY    004 BETTY    KIL      001 ALL  *NONE*  YES   000 000 2351 
;           
   run;     
            
proc print; 
   run;     &lt;/PRE&gt;&lt;P&gt;This is what I would like to see:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Name		lastrun		rqmt		leadtm	
FREDFRED	1732	
BARNEY	        1341		JOB0001 	08
BARNEY	        1341		JOB00043	
WILMA		0000		STEP9999	99
BETTY		2351&lt;/PRE&gt;&lt;P&gt;I can't seem to figure out how to handle those entries consisting of multiple lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any assistance. Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Dec 2025 19:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980392#M43586</guid>
      <dc:creator>serge68</dc:creator>
      <dc:date>2025-12-08T19:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using more than one Input statement to combine data lines</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980396#M43587</link>
      <description>&lt;P&gt;It would be easier to read from a file, since you can use the END= option of the INFILE statement.&lt;/P&gt;
&lt;P&gt;So let's convert your example lines into a file first so we have something to program against.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=text;
filename text temp;

parmcards;                                                          
FREDFRED 004 FREDFRED FMS      001 ALL  *NONE*  YES   000 000 1732 
BARNEY   004 BARNEY   ABZ      001 ALL  *NONE*  YES   000 000 1341 
JOB=JOB00001        SCHID=000   VRSN=09063/1602   LEADTM=08        
JOB=JOB00043        SCHID=000   VRSN=94322/1613                    
WILMA    004 WILMA    TRE      001 ALL  *NONE*  YES   000 000 0000 
JOB=STEP9999        SCHID=000   VRSN=07263/0650   LEADTM=99        
BETTY    004 BETTY    KIL      001 ALL  *NONE*  YES   000 000 2351 
;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can read ahead using trailing&amp;nbsp;@@ on the INPUT statement.&amp;nbsp; Keep track of how many JOB= lines you have seen so you know whether you need to execute and extra OUTPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably do NOT want the behavior of the MISSOVER option, instead use TRUNCOVER so it doesn't ignore short values at the end of lines.&amp;nbsp; And to read those JOB= lines you could use @ 'string' pointer control.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;                                                         
   infile text truncover end=eof;  
   input name $ 1-8 lastrun $ 63-66;
   do n=0 by 1 while(not eof);
     input @@;
     if _infile_ =: 'JOB=' then do;
       if n then output;
       input @'JOB=' rqmt :$8. @'LEADTM=' leadtm :$2. ;
     end;
     else leave;
   end;
   output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you make the variable names match the strings in the lines you can used NAMED input style.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;                                                         
   infile text truncover end=eof;  
   input name $ 1-8 lastrun $ 63-66;
   do n=0 by 1 while(not eof);
     input @@;
     if _infile_ =: 'JOB=' then do;
       if n then output;
       input job= :$8. leadtm= :$2. ;
     end;
     else leave;
   end;
   output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-12-08 at 2.59.30 PM.png" style="width: 462px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/112024iF05FFA9895CF8E2C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-12-08 at 2.59.30 PM.png" alt="Screenshot 2025-12-08 at 2.59.30 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Notice that using the named input caused the LEADTM value to be remembered for the second JOB= line.&lt;/P&gt;
&lt;P&gt;To fix the issue that named input does not force variables to missing when not found you could add code to clear the value before the input.&amp;nbsp; But make sure to set the variable's type and length before hand.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;                                                         
   infile text truncover end=eof;  
   input name $ 1-8 lastrun $ 63-66;
   do n=0 by 1 while(not eof);
     input @@;
     if _infile_ =: 'JOB=' then do;
       if n then output;
       length job $8 leadtm $2 ;
       call missing(job,leadtm);
       input job= leadtm= ;
     end;
     else leave;
   end;
   output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Dec 2025 20:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980396#M43587</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-12-08T20:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using more than one Input statement to combine data lines</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980406#M43588</link>
      <description>&lt;P&gt;You could also just generate two datasets and then merge them together.&lt;/P&gt;
&lt;P&gt;Create a unique id to perform the merge with, let's call it ID.&lt;/P&gt;
&lt;P&gt;To make the named input happy define variables for all of the named fields on the JOB= lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data main jobs(drop=name lastrun);
   infile cards truncover ;
   input @;
   if _infile_ ^=: 'JOB=' then do;
     id+1;
     n=0;
     input name $ 1-8 lastrun $ 63-66;
     output main;
   end;
   else do;
     n+1;
     length job $8 schid $3 vrsn $10 leadtm $2;
     input (job--leadtm) (=)  ;
     output jobs;
   end;
cards;                                                          
FREDFRED 004 FREDFRED FMS      001 ALL  *NONE*  YES   000 000 1732 
BARNEY   004 BARNEY   ABZ      001 ALL  *NONE*  YES   000 000 1341 
JOB=JOB00001        SCHID=000   VRSN=09063/1602   LEADTM=08        
JOB=JOB00043        SCHID=000   VRSN=94322/1613                    
WILMA    004 WILMA    TRE      001 ALL  *NONE*  YES   000 000 0000 
JOB=STEP9999        SCHID=000   VRSN=07263/0650   LEADTM=99        
BETTY    004 BETTY    KIL      001 ALL  *NONE*  YES   000 000 2351 
;

data want;
  merge main jobs;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-12-08 at 4.36.07 PM.png" style="width: 666px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/112028i123FCA2ED1A34719/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-12-08 at 4.36.07 PM.png" alt="Screenshot 2025-12-08 at 4.36.07 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Dec 2025 21:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980406#M43588</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-12-08T21:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using more than one Input statement to combine data lines</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980521#M43589</link>
      <description>&lt;PRE&gt;data have;                                                         
infile cards truncover ;
length a1-a11 job schid vrsn LEADTM $ 80;
retain a1-a11;
input @;
if _infile_ =: 'JOB=' then  input job= schid= vrsn= LEADTM= ;
 else do;input a1-a11;id+1;end;
cards;                                                          
FREDFRED 004 FREDFRED FMS      001 ALL  *NONE*  YES   000 000 1732 
BARNEY   004 BARNEY   ABZ      001 ALL  *NONE*  YES   000 000 1341 
JOB=JOB00001        SCHID=000   VRSN=09063/1602   LEADTM=08        
JOB=JOB00043        SCHID=000   VRSN=94322/1613                    
WILMA    004 WILMA    TRE      001 ALL  *NONE*  YES   000 000 0000 
JOB=STEP9999        SCHID=000   VRSN=07263/0650   LEADTM=99        
BETTY    004 BETTY    KIL      001 ALL  *NONE*  YES   000 000 2351 
;           

data want(rename=(a1=name a11=lastrun job=rqmt ));
 set have(keep=id a1 a11 job leadtm);
 by id;
 if first.id and last.id then output;
  else do;
   if not first.id then output;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1765440156378.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/112145i385553751C0B886F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1765440156378.png" alt="Ksharp_0-1765440156378.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 08:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-more-than-one-Input-statement-to-combine-data-lines/m-p/980521#M43589</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-12-11T08:02:41Z</dc:date>
    </item>
  </channel>
</rss>

