<?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: importing  Hierarchical Files in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582083#M7858</link>
    <description>&lt;P&gt;Just to be sure, the transaction data are the rows with dollar amounts in them and the header data are the rows without dates in them, correct?&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2019 11:53:35 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-08-19T11:53:35Z</dc:date>
    <item>
      <title>importing  Hierarchical Files</title>
      <link>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582082#M7857</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;the file contains different types of information for each Client_id, State, DoB in header row and different purchases carried out on different dates in transaction row. Import the data into SAS by retaining client_id and State such that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i) Only transaction data is imported&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ii) Only header data is imported&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;H 1095 NJ 06DEC84&lt;BR /&gt;C 01DEC11 $45.0&lt;BR /&gt;C 01AUG11 $37.5&lt;BR /&gt;H 1096 CA 01SEP83&lt;BR /&gt;C 01JUL11 $156.7&lt;BR /&gt;H 1097 VG 07JUL74&lt;BR /&gt;C 01FEB11 $109.5&lt;BR /&gt;H 1099 OT 13FEB79&lt;BR /&gt;C 01Mar11 $45.0&lt;BR /&gt;C 01May11 $45.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Guys can you help me how to import this. I have tried by a lot of ways but I couldn't do this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582082#M7857</guid>
      <dc:creator>u39734216</dc:creator>
      <dc:date>2019-08-19T11:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: importing  Hierarchical Files</title>
      <link>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582083#M7858</link>
      <description>&lt;P&gt;Just to be sure, the transaction data are the rows with dollar amounts in them and the header data are the rows without dates in them, correct?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582083#M7858</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-19T11:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: importing  Hierarchical Files</title>
      <link>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582085#M7859</link>
      <description>&lt;P&gt;Also, do you have the indicator variable with H or C values in your actual data?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582085#M7859</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-19T11:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: importing  Hierarchical Files</title>
      <link>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582086#M7860</link>
      <description>&lt;P&gt;Importing only transaction data makes not sense (from my point of view).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need multiple input-statements: the first reads only&amp;nbsp; the row-type. Then, depending on the value, you use an input-statement for reading h or c rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a data step reading everything:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data everything;
   length 
      RowType $ 1
      ClientId 8
      State $ 2
      DoB 8
      PurchaseDate 8
      Amount 8
   ;
   retain ClientId State DoB;

   format Dob PurchaseDate Date.;
   informat 
      Dob PurchaseDate Date.
      Amount comma.
   ;

   drop RowType;

   input RowType @;

   if RowType = 'H' then do;
      input ClientID State DoB;
   end;
   else do;
      if RowType = 'C' then do;
         input PurchaseDate Amount;
         output;
      end;
   end;

datalines;
H 1095 NJ 06DEC84
C 01DEC11 $45.0
C 01AUG11 $37.5
H 1096 CA 01SEP83
C 01JUL11 $156.7
H 1097 VG 07JUL74
C 01FEB11 $109.5
H 1099 OT 13FEB79
C 01Mar11 $45.0
C 01May11 $45.0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582086#M7860</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-08-19T11:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: importing  Hierarchical Files</title>
      <link>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582087#M7861</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Importing only transaction data makes not sense (from my point of view)."&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;+1&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 12:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582087#M7861</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-19T12:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: importing  Hierarchical Files</title>
      <link>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582115#M7862</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283659"&gt;@u39734216&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;the file contains different types of information for each Client_id, State, DoB in header row and different purchases carried out on different dates in transaction row. Import the data into SAS by retaining client_id and State such that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i) Only transaction data is imported&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ii) Only header data is imported&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;H 1095 NJ 06DEC84&lt;BR /&gt;C 01DEC11 $45.0&lt;BR /&gt;C 01AUG11 $37.5&lt;BR /&gt;H 1096 CA 01SEP83&lt;BR /&gt;C 01JUL11 $156.7&lt;BR /&gt;H 1097 VG 07JUL74&lt;BR /&gt;C 01FEB11 $109.5&lt;BR /&gt;H 1099 OT 13FEB79&lt;BR /&gt;C 01Mar11 $45.0&lt;BR /&gt;C 01May11 $45.0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Guys can you help me how to import this. I have tried by a lot of ways but I couldn't do this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If this is reading a text file of some sort then you should provide an example of what that text file actually looks like, the actual file not some value from it. Copy from the text file and paste into a code box opened on the forum using the {I} icon. Edit any sensitive names with something like XXXXX or YYYY as needed, but the actual layout of the file is often important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you may want to have a discussion with the originator about the not-quite-up-to-snuff use of 2-digit years.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582115#M7862</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-19T16:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: importing  Hierarchical Files</title>
      <link>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582121#M7863</link>
      <description>I think I would use SELECT instead of IF THEN ELSE to handle the record type.  That would automatically signal an error if an unexpected code shows up, and will be easier to expand if the next homework assignment is more complicated.</description>
      <pubDate>Mon, 19 Aug 2019 14:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/importing-Hierarchical-Files/m-p/582121#M7863</guid>
      <dc:creator>JackHamilton</dc:creator>
      <dc:date>2019-08-19T14:54:18Z</dc:date>
    </item>
  </channel>
</rss>

