<?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: Read Multiple Line Per Subject in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831025#M6145</link>
    <description>&lt;P&gt;If every instance is composed of three lines (line1 for the name, line2 and line3 with other data), you could issue three INPUT sand two PUTs, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  input name $char25.;
  do i=1 to 2;
    input line $80.;  
    put name $25. line;
  end;
datalines;
John,Doe
EW202207070053899 FOR RESOLUTION W260560364 JUNGE NAT POB 098 169644
EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087
Mitchelle, Stark
EW202205020079881 SEE NOTES W268135093 LEE SGB FAX 738 177390
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, the PUT above writes to the log,&amp;nbsp; You either want to make a new text file (2 lines per person) or a SAS dataset (2 obs per person).&amp;nbsp; In the latter case, you have to modify the INPUT statement inside the loop to read each individual variable in the data lines, and then use OUTPUT instead of PUT, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input name $char25.;
  do i=1 to 2;
    input ..... specify input variables here ...;  
    output;
  end;
datalines;
John,Doe
EW202207070053899 FOR RESOLUTION W260560364 JUNGE NAT POB 098 169644
EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087
Mitchelle, Stark
EW202205020079881 SEE NOTES W268135093 LEE SGB FAX 738 177390
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Aug 2022 03:46:20 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-08-30T03:46:20Z</dc:date>
    <item>
      <title>Read Multiple Line Per Subject</title>
      <link>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/830846#M6143</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am facing a challenge while reading a csv file with the data spread in multiple lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample:&lt;/P&gt;&lt;P&gt;John,Doe&lt;/P&gt;&lt;P&gt;EW202207070053899 FOR RESOLUTION W260560364 JUNGE NAT POB 098 169644&lt;BR /&gt;EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Mitchelle, Stark&lt;/P&gt;&lt;P&gt;EW202205020079881 SEE NOTES W268135093 LEE SGB FAX 738 177390&lt;BR /&gt;EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me to read think in the following way:&lt;/P&gt;&lt;P&gt;Mitchelle, Stark&amp;nbsp;EW202207070053899 FOR RESOLUTION W260560364 JUNGE NAT POB 098 169644&lt;/P&gt;&lt;P&gt;Mitchelle, Stark&amp;nbsp;EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087&lt;/P&gt;&lt;P&gt;Mitchelle, Stark&amp;nbsp;EW202205020079881 SEE NOTES W268135093 LEE SGB FAX 738 177390&lt;/P&gt;&lt;P&gt;Mitchelle, Stark&amp;nbsp;EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 07:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/830846#M6143</guid>
      <dc:creator>Ninja_turtle</dc:creator>
      <dc:date>2022-08-29T07:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Read Multiple Line Per Subject</title>
      <link>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831025#M6145</link>
      <description>&lt;P&gt;If every instance is composed of three lines (line1 for the name, line2 and line3 with other data), you could issue three INPUT sand two PUTs, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  input name $char25.;
  do i=1 to 2;
    input line $80.;  
    put name $25. line;
  end;
datalines;
John,Doe
EW202207070053899 FOR RESOLUTION W260560364 JUNGE NAT POB 098 169644
EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087
Mitchelle, Stark
EW202205020079881 SEE NOTES W268135093 LEE SGB FAX 738 177390
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, the PUT above writes to the log,&amp;nbsp; You either want to make a new text file (2 lines per person) or a SAS dataset (2 obs per person).&amp;nbsp; In the latter case, you have to modify the INPUT statement inside the loop to read each individual variable in the data lines, and then use OUTPUT instead of PUT, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input name $char25.;
  do i=1 to 2;
    input ..... specify input variables here ...;  
    output;
  end;
datalines;
John,Doe
EW202207070053899 FOR RESOLUTION W260560364 JUNGE NAT POB 098 169644
EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087
Mitchelle, Stark
EW202205020079881 SEE NOTES W268135093 LEE SGB FAX 738 177390
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2022 03:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831025#M6145</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-08-30T03:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Read Multiple Line Per Subject</title>
      <link>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831037#M6146</link>
      <description>Thank you for the response, but the challenge is the rows after name are not fixed to 2,they can be n number of rows for every name.</description>
      <pubDate>Tue, 30 Aug 2022 06:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831037#M6146</guid>
      <dc:creator>Ninja_turtle</dc:creator>
      <dc:date>2022-08-30T06:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Read Multiple Line Per Subject</title>
      <link>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831044#M6147</link>
      <description>&lt;P&gt;Have a look at the code below. It shows how to determine the "type" of record and process it accordingly.&lt;/P&gt;
&lt;P&gt;See also&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/basess/p1t8p3j0o4arenn1m0g4wmvpxjip.htm" target="_blank" rel="noopener"&gt;Testing a Condition Before Creating an Observation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile cards truncover;
  /*
   * define variables
   */
  length
    type $ 2
    name $ 25
    line $ 80
  ;
  /*
   * read a record 
   * and keep it in the buffer, the @ at the end
   */
  input 
    @1 type $2.
    @
  ;
  /*
   * check for type of record, the logic may vary depending
   * on the data
   *
   * if EW, then process detail
   * else process "header"   
   */
  if type = "EW" then do;
    input @1 line $80.;
    output;
  end;
  else do;
    retain name;
    input @1 name $25.;
  end;  
datalines;
John,Doe
EW202207070053899 FOR RESOLUTION W260560364 JUNGE NAT POB 098 169644
EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087
EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087
Mitchelle, Stark
EW202205020079881 SEE NOTES W268135093 LEE SGB FAX 738 177390
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2022 07:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831044#M6147</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2022-08-30T07:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Read Multiple Line Per Subject</title>
      <link>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831069#M6148</link>
      <description>&lt;PRE&gt;data want;
infile cards truncover;
input col $200.;
length name value $ 200;
retain name;
if prxmatch('/[a-z]+,/i',col) then do;name=col;delete;end;
 else value=col;
drop col;
datalines;
John,Doe
EW202207070053899 FOR RESOLUTION W260560364 JUNGE NAT POB 098 169644
EW202207070055230 FOR RESOLUTION W263027005 RACE NAT PPS 114 161087
Mitchelle, Stark
EW202205020079881 SEE NOTES W268135093 LEE SGB FAX 738 177390
EW202206270042457 FOR RESOLUTION W255586930 RIGGS NAT FAX 754 737493
;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2022 11:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Read-Multiple-Line-Per-Subject/m-p/831069#M6148</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-08-30T11:39:57Z</dc:date>
    </item>
  </channel>
</rss>

