<?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: Two-dimensional Array for Table Lookup in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Two-dimensional-Array-for-Table-Lookup/m-p/29293#M5509</link>
    <description>I would use 2 arrays to hold the values of the dataset. One array with one dimension that would keep the WT values (a row) and that would be used to load another array having two dimensions: one for WT and one for Group.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data look_up2;&lt;BR /&gt;
Array price{70,9};&lt;BR /&gt;
&lt;BR /&gt;
Do i=1 to 70;&lt;BR /&gt;
  &lt;BR /&gt;
   Array wt_row[*} A--I;&lt;BR /&gt;
   Do j=1 to dim(wt_row);&lt;BR /&gt;
      price{wt, j}=wt_row{j};&lt;BR /&gt;
   End;&lt;BR /&gt;
End;&lt;BR /&gt;
&lt;BR /&gt;
Run;</description>
    <pubDate>Tue, 08 Jul 2008 07:37:02 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-07-08T07:37:02Z</dc:date>
    <item>
      <title>Two-dimensional Array for Table Lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-dimensional-Array-for-Table-Lookup/m-p/29292#M5508</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I need to use a two-dimensional array to perform a table lookup.&lt;BR /&gt;
&lt;BR /&gt;
I have a text file that looks like this (the dots represent continuous data, I didn't want to type out all 630 observations):&lt;BR /&gt;
 &lt;BR /&gt;
WT A B...I   &lt;BR /&gt;
1 17.00 18.25 ... 21.65&lt;BR /&gt;
2 22.50 19.75 ... 22.85&lt;BR /&gt;
.    .    .           &lt;BR /&gt;
.    .    .            &lt;BR /&gt;
.    .    .      &lt;BR /&gt;
69 28.95 31.80 ... 36.25&lt;BR /&gt;
70 32.60 34.95 ... 37.05&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset with entries having the variables WT and Group (A-I).  I would like a code that will give me the price, based on the WT and Group of an item.  So for an item that weighed 2 and was in group B, 19.75 would be outputed.&lt;BR /&gt;
&lt;BR /&gt;
I tried doing something like this, but couldn't get it to work.&lt;BR /&gt;
&lt;BR /&gt;
FILENAME RATES 'F:\Rate.txt';&lt;BR /&gt;
DATA LOOK_UP;&lt;BR /&gt;
 ARRAY Price{70,9};&lt;BR /&gt;
 infile RATES;&lt;BR /&gt;
  do WT = 1 to 70;&lt;BR /&gt;
   do Group = 1 to 9;&lt;BR /&gt;
	input Price{WT,Group} @;&lt;BR /&gt;
   end;&lt;BR /&gt;
  end;&lt;BR /&gt;
 set PCDTX2;&lt;BR /&gt;
 Group = input(translate(GROUP,'12345689','ABCDEFGHI'),1.);&lt;BR /&gt;
  Revenue= Price{WT,Group};&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Any help would be appreciated.  Thank you.&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: stat11

Message was edited by: stat11</description>
      <pubDate>Mon, 07 Jul 2008 21:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-dimensional-Array-for-Table-Lookup/m-p/29292#M5508</guid>
      <dc:creator>stat11</dc:creator>
      <dc:date>2008-07-07T21:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Two-dimensional Array for Table Lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-dimensional-Array-for-Table-Lookup/m-p/29293#M5509</link>
      <description>I would use 2 arrays to hold the values of the dataset. One array with one dimension that would keep the WT values (a row) and that would be used to load another array having two dimensions: one for WT and one for Group.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data look_up2;&lt;BR /&gt;
Array price{70,9};&lt;BR /&gt;
&lt;BR /&gt;
Do i=1 to 70;&lt;BR /&gt;
  &lt;BR /&gt;
   Array wt_row[*} A--I;&lt;BR /&gt;
   Do j=1 to dim(wt_row);&lt;BR /&gt;
      price{wt, j}=wt_row{j};&lt;BR /&gt;
   End;&lt;BR /&gt;
End;&lt;BR /&gt;
&lt;BR /&gt;
Run;</description>
      <pubDate>Tue, 08 Jul 2008 07:37:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-dimensional-Array-for-Table-Lookup/m-p/29293#M5509</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-08T07:37:02Z</dc:date>
    </item>
  </channel>
</rss>

