<?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 how to read heirarchial files in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-heirarchial-files/m-p/676672#M23730</link>
    <description>&lt;P&gt;i have a code like this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;P 1095 SMITH, HOWARD                                                            
C 01-08-11 $45.0                                                                
C 01-17-11 $37.5                                                                
P 1096 BARCLAY, NICK                                                            
C 01-09-11 $150.5                                                               
P 1097 REISCH, DEBORAH                                                          
C 01-02-11 $109.0 
C 03-02-11 $100.0                                                              
P 1099 WILSON, ERNEST                                                           
C 01-03-11 $45.0                                                                
C 01-05-11 $45.0      &lt;/PRE&gt;&lt;P&gt;and i need it to convert it to like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Obs name id date sales
1 SMITH, HOWARD 1095 01/08/11 $45.00
2 SMITH, HOWARD 1095 01/17/11 $37.50
3 BARCLAY, NICK 1096 01/09/11 $150.50
4 REISCH, DEBORAH 1097 01/02/11 $109.00
5 REISCH, DEBORAH 1097 03/02/11 $100.00
6 WILSON, ERNEST 1099 01/03/11 $45.00
7 WILSON, ERNEST 1099 01/05/11 $45.00&lt;/PRE&gt;&lt;P&gt;how to get the result. Any leads?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Aug 2020 10:00:31 GMT</pubDate>
    <dc:creator>Raj00007</dc:creator>
    <dc:date>2020-08-14T10:00:31Z</dc:date>
    <item>
      <title>how to read heirarchial files</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-heirarchial-files/m-p/676672#M23730</link>
      <description>&lt;P&gt;i have a code like this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;P 1095 SMITH, HOWARD                                                            
C 01-08-11 $45.0                                                                
C 01-17-11 $37.5                                                                
P 1096 BARCLAY, NICK                                                            
C 01-09-11 $150.5                                                               
P 1097 REISCH, DEBORAH                                                          
C 01-02-11 $109.0 
C 03-02-11 $100.0                                                              
P 1099 WILSON, ERNEST                                                           
C 01-03-11 $45.0                                                                
C 01-05-11 $45.0      &lt;/PRE&gt;&lt;P&gt;and i need it to convert it to like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Obs name id date sales
1 SMITH, HOWARD 1095 01/08/11 $45.00
2 SMITH, HOWARD 1095 01/17/11 $37.50
3 BARCLAY, NICK 1096 01/09/11 $150.50
4 REISCH, DEBORAH 1097 01/02/11 $109.00
5 REISCH, DEBORAH 1097 03/02/11 $100.00
6 WILSON, ERNEST 1099 01/03/11 $45.00
7 WILSON, ERNEST 1099 01/05/11 $45.00&lt;/PRE&gt;&lt;P&gt;how to get the result. Any leads?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 10:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-heirarchial-files/m-p/676672#M23730</guid>
      <dc:creator>Raj00007</dc:creator>
      <dc:date>2020-08-14T10:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to read heirarchial files</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-heirarchial-files/m-p/676676#M23732</link>
      <description>&lt;P&gt;Please try the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input col1:$ col2$ col3:&amp;amp;$100.;
cards;
P 1095 SMITH, HOWARD                                                            
C 01-08-11 $45.0                                                                
C 01-17-11 $37.5                                                                
P 1096 BARCLAY, NICK                                                            
C 01-09-11 $150.5                                                               
P 1097 REISCH, DEBORAH                                                          
C 01-02-11 $109.0 
C 03-02-11 $100.0                                                              
P 1099 WILSON, ERNEST                                                           
C 01-03-11 $45.0                                                                
C 01-05-11 $45.0      
;

data want;
set have;
retain name id;
if col1='P' then do;
name=col3;
id=col2;
end;
else if col1='C' then do;
date=input(col2,mmddyy10.);
sale=col3;
end;
format date mmddyys8.;
if col1='C';
drop col:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 10:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-heirarchial-files/m-p/676676#M23732</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-08-14T10:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to read heirarchial files</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-heirarchial-files/m-p/676683#M23734</link>
      <description>&lt;P&gt;In the beginning of SAS this type of data was very common, so the DATA Step can deal with this quite easy, see code sample below. The important part is the&amp;nbsp;@ at the end of the INPUT statement, it will keep the current record in the input buffer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you first read the type of the record and then use the different INPUT statement to read the rest of the current line. You do need to use the RETAIN on the variables from the "header" line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards dlm=" ";
  input
    type : $1.
    @
  ;
  retain id lname fname;
  if type = "P" then do;    
    input
      id : 8.
      lname : $32.
      fname : $32.
    ;
  end;

  if type = "C" then do;
    input 
      date : mmddyy.
      someDollar : dollar.
    ;
    output;
  end;&lt;BR /&gt;  format date date9.;&lt;BR /&gt;  *drop type;

  cards;
P 1095 SMITH, HOWARD                                                            
C 01-08-11 $45.0                                                                
C 01-17-11 $37.5                                                                
P 1096 BARCLAY, NICK                                                            
C 01-09-11 $150.5                                                               
P 1097 REISCH, DEBORAH                                                          
C 01-02-11 $109.0 
C 03-02-11 $100.0                                                              
P 1099 WILSON, ERNEST                                                           
C 01-03-11 $45.0                                                                
C 01-05-11 $45.0      
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 11:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-heirarchial-files/m-p/676683#M23734</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2020-08-14T11:03:23Z</dc:date>
    </item>
  </channel>
</rss>

