<?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 Hash or Array solution ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489113#M127605</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some guidelines to proceed with my requirement. Here are the details:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#1)&amp;nbsp; I have a input txt file data as below:-&lt;/P&gt;&lt;P&gt;Row1 --&amp;gt;123456 Transact1 Transact2 Transact3&lt;/P&gt;&lt;P&gt;Row2--&amp;gt; 456789 Transac1&amp;nbsp; Transact2&lt;/P&gt;&lt;P&gt;Note :&amp;nbsp; We don't know about the position of the data in the file. Numbers in the first position are the employee ids and followed by transaction types.&lt;/P&gt;&lt;P&gt;I have to read the input file and create a dataset "InptData" with two columns and it's corresponding vaues. How we can read this ?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EmployeeID TransactionType&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#2) I have queried from database and created another dataset 'Details' with below values:-&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TransactionType&amp;nbsp; Service&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Transact1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Transact2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A2&lt;/P&gt;&lt;P&gt;Transact3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1&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;P&gt;I have to merge&amp;nbsp; #1 and #2 datasets to determine the &lt;STRONG&gt;Service&lt;/STRONG&gt; for each transactions for the employee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.Once we determined the service ,I have to output the data to different fles:-&lt;/P&gt;&lt;P&gt;If service is A1 then output to File1&lt;/P&gt;&lt;P&gt;If service is A2 then output to File2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please someone guide me on the SAS functionality for this requirement ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help .&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Aug 2018 03:01:13 GMT</pubDate>
    <dc:creator>AshokD</dc:creator>
    <dc:date>2018-08-23T03:01:13Z</dc:date>
    <item>
      <title>Hash or Array solution ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489113#M127605</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some guidelines to proceed with my requirement. Here are the details:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#1)&amp;nbsp; I have a input txt file data as below:-&lt;/P&gt;&lt;P&gt;Row1 --&amp;gt;123456 Transact1 Transact2 Transact3&lt;/P&gt;&lt;P&gt;Row2--&amp;gt; 456789 Transac1&amp;nbsp; Transact2&lt;/P&gt;&lt;P&gt;Note :&amp;nbsp; We don't know about the position of the data in the file. Numbers in the first position are the employee ids and followed by transaction types.&lt;/P&gt;&lt;P&gt;I have to read the input file and create a dataset "InptData" with two columns and it's corresponding vaues. How we can read this ?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EmployeeID TransactionType&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#2) I have queried from database and created another dataset 'Details' with below values:-&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TransactionType&amp;nbsp; Service&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Transact1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Transact2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A2&lt;/P&gt;&lt;P&gt;Transact3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1&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;P&gt;I have to merge&amp;nbsp; #1 and #2 datasets to determine the &lt;STRONG&gt;Service&lt;/STRONG&gt; for each transactions for the employee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.Once we determined the service ,I have to output the data to different fles:-&lt;/P&gt;&lt;P&gt;If service is A1 then output to File1&lt;/P&gt;&lt;P&gt;If service is A2 then output to File2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please someone guide me on the SAS functionality for this requirement ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help .&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 03:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489113#M127605</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2018-08-23T03:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Hash or Array solution ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489120#M127610</link>
      <description>&lt;P&gt;Neither of these need hash or array. A data step should work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@Some hints, look up the trailing&amp;nbsp;@@ or _infile_ for number 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your second question look up the OUTPUT statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/56202"&gt;@AshokD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some guidelines to proceed with my requirement. Here are the details:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#1)&amp;nbsp; I have a input txt file data as below:-&lt;/P&gt;
&lt;P&gt;Row1 --&amp;gt;123456 Transact1 Transact2 Transact3&lt;/P&gt;
&lt;P&gt;Row2--&amp;gt; 456789 Transac1&amp;nbsp; Transact2&lt;/P&gt;
&lt;P&gt;Note :&amp;nbsp; We don't know about the position of the data in the file. Numbers in the first position are the employee ids and followed by transaction types.&lt;/P&gt;
&lt;P&gt;I have to read the input file and create a dataset "InptData" with two columns and it's corresponding vaues. How we can read this ?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;EmployeeID TransactionType&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#2) I have queried from database and created another dataset 'Details' with below values:-&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TransactionType&amp;nbsp; Service&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Transact1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transact2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A2&lt;/P&gt;
&lt;P&gt;Transact3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1&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;P&gt;I have to merge&amp;nbsp; #1 and #2 datasets to determine the &lt;STRONG&gt;Service&lt;/STRONG&gt; for each transactions for the employee&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.Once we determined the service ,I have to output the data to different fles:-&lt;/P&gt;
&lt;P&gt;If service is A1 then output to File1&lt;/P&gt;
&lt;P&gt;If service is A2 then output to File2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please someone guide me on the SAS functionality for this requirement ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for your help .&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 03:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489120#M127610</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-23T03:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Hash or Array solution ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489125#M127614</link>
      <description>&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  informat TRANSACTIONTYPE $10.;
  infile cards missover truncover;
  input EMPLOYEEID @ ;
  do until (TRANSACTIONTYPE=' '); 
    input TRANSACTIONTYPE $ @;
    if TRANSACTIONTYPE ne ' ' then output;
  end;
cards;
123456 Transact1 Transact2 Transact3
456789 Transact1 Transact2
run;

proc sort data=HAVE; 
  by TRANSACTIONTYPE;
run;

data DETAILS;
  informat TRANSACTIONTYPE $10.;
  input TRANSACTIONTYPE $ SERVICE $;
cards;
Transact1 A1        
Transact2 A2
Transact3 A1
run;

data FILE1
     FILE2;
  merge HAVE DETAILS;
  by TRANSACTIONTYPE;
  if SERVICE='A1' then output FILE1;
  if SERVICE='A2' then output FILE2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A few assumptions about the data are made here.&lt;/P&gt;
&lt;P&gt;Please understand the steps, as described at&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, to correct and fit to your exact needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 04:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489125#M127614</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-23T04:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Hash or Array solution ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489130#M127618</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this will work but need a small clarification.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having nearly 100+ transaction types so can you please suggest logic&amp;nbsp;using array or hash instead of merge step so that it performs faster?&lt;/P&gt;&lt;P&gt;Please correct me if I am wrong.&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 05:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489130#M127618</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2018-08-23T05:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Hash or Array solution ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489139#M127625</link>
      <description>&lt;P&gt;If performance is an issue I would create formats from the details table and apply them in the very first data step. This way you only have one step.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 06:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489139#M127625</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-23T06:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Hash or Array solution ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489150#M127636</link>
      <description>&lt;P&gt;You don't need a merge at all, you do it in one data step with a format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cntlin;
input start :$20. label $;
fmtname = "transacts";
type = 'C';
cards;
Transact1 A1
Transact2 A2
Transact3 A1
;
run;

proc format lib=work cntlin=cntlin;
run;

data
  a1
  a2
;
infile cards truncover;
length empid $6 transactiontype $10;
input;
empid = scan(_infile_,1);
do i = 2 to countw(_infile_);
  transactiontype = scan(_infile_,i);
  select (put(transactiontype,$transacts.));
    when ('A1') output a1;
    when ('A2') output a2;
    otherwise;
  end;
end;
drop i;
cards; 
123456 Transact1 Transact2 Transact3
456789 Transact1 Transact2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might want to remove the otherwise to get an ERROR if you catch an unexpected transaction type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 07:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489150#M127636</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-23T07:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Hash or Array solution ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489211#M127681</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the inputs and suggestion.&lt;/P&gt;&lt;P&gt;I will try both the methods and let's see which one suits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your time and help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 11:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489211#M127681</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2018-08-23T11:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Hash or Array solution ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489950#M128056</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961" target="_blank"&gt;@ChrisNZ&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_blank"&gt;@KurtBremser&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879" target="_blank"&gt;@Reeza&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using proc format method is working fine but the requirement is need in hash table lookup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please suggest a logic on hash table ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 00:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-or-Array-solution/m-p/489950#M128056</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2018-08-27T00:14:33Z</dc:date>
    </item>
  </channel>
</rss>

