<?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 Reading SAS data into Excel in Microsoft Integration with SAS</title>
    <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/103#M12</link>
    <description>I have a SAS data set with two variables, ID and AMOUNT. The file is indexed on ID (no ID duplicates). I would like to write a VB function in Excel that would return the value of AMOUNT corresponding to a given ID. That is, like the VLOOKUP function in Excel, but reading data from the SAS dataset. I would probably have 200 or so lookups in a single spreadsheet, so the lookup would have to be reasonably efficient. &lt;BR /&gt;
&lt;BR /&gt;
Which is the best technology to use for this? My thinking at the moment is to use ADO with the local data provider (that way I don't need to have a SAS session running). I'm concerned though that this might be too slow if my input dataset gets too large. &lt;BR /&gt;
&lt;BR /&gt;
Is ADO the best strategy here?</description>
    <pubDate>Tue, 14 Mar 2006 04:52:16 GMT</pubDate>
    <dc:creator>BruceBrad</dc:creator>
    <dc:date>2006-03-14T04:52:16Z</dc:date>
    <item>
      <title>Reading SAS data into Excel</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/103#M12</link>
      <description>I have a SAS data set with two variables, ID and AMOUNT. The file is indexed on ID (no ID duplicates). I would like to write a VB function in Excel that would return the value of AMOUNT corresponding to a given ID. That is, like the VLOOKUP function in Excel, but reading data from the SAS dataset. I would probably have 200 or so lookups in a single spreadsheet, so the lookup would have to be reasonably efficient. &lt;BR /&gt;
&lt;BR /&gt;
Which is the best technology to use for this? My thinking at the moment is to use ADO with the local data provider (that way I don't need to have a SAS session running). I'm concerned though that this might be too slow if my input dataset gets too large. &lt;BR /&gt;
&lt;BR /&gt;
Is ADO the best strategy here?</description>
      <pubDate>Tue, 14 Mar 2006 04:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/103#M12</guid>
      <dc:creator>BruceBrad</dc:creator>
      <dc:date>2006-03-14T04:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reading SAS data into Excel</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/104#M13</link>
      <description>I can think of several ways to accomplish VLOOKUP, or VLOOKUP-like, functionality using SAS data.  The one that comes to mind is:&lt;BR /&gt;
&lt;BR /&gt;
1. Pull the data into Excel using either SAS Add-In for Microsoft Office or one of the SAS OLEDB data providers (Local Data Provider in your case).&lt;BR /&gt;
2. Use the Excel VLOOKUP function against that now Excel resident table.&lt;BR /&gt;
3. Use VB to refresh the Excel view of the SAS data as necessary.&lt;BR /&gt;
&lt;BR /&gt;
An alternative would be to do a SQL query for each lookup value via ADO/OLEDB or even SAS Add-In for Microsoft Office.  I think this would require more, and more complex, code writing but would remove the limitation of the data fitting into one worksheet (65536 row max) and having to refresh Excel's view of the data.  For this, you are correct, ADO would be the best choice.</description>
      <pubDate>Tue, 14 Mar 2006 14:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/104#M13</guid>
      <dc:creator>Bill_SAS</dc:creator>
      <dc:date>2006-03-14T14:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Reading SAS data into Excel</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/105#M14</link>
      <description>Below is some ADO code that works for a small file at least. Not being very familiar with VB, I was surprised how easy it was. This needs to be entered as an Excel VB module, with a reference to the Microsoft ActiveX Data Objects Library activated. &lt;BR /&gt;
&lt;BR /&gt;
Does the local data provider support the SEEK property (which would use an index to find the relevant record)?&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Function SASLookup(ID, folder As String, sasfile As String)&lt;BR /&gt;
&lt;BR /&gt;
Dim obConnection As New ADODB.Connection&lt;BR /&gt;
Dim obRecordset As New ADODB.Recordset&lt;BR /&gt;
obConnection.Provider = "sas.LocalProvider"&lt;BR /&gt;
obConnection.Properties("Data Source") = folder&lt;BR /&gt;
obConnection.Open&lt;BR /&gt;
obRecordset.Open sasfile, obConnection, adOpenKeyset, adLockReadOnly, adCmdTableDirect&lt;BR /&gt;
   &lt;BR /&gt;
With obRecordset&lt;BR /&gt;
     .Filter = "ID='" &amp;amp; ID &amp;amp; "'"&lt;BR /&gt;
     If .EOF Then&lt;BR /&gt;
          SASLookup = "Not found"&lt;BR /&gt;
     ElseIf .RecordCount = -1 Then&lt;BR /&gt;
          SASLookup = "Cannot calculate number of records"&lt;BR /&gt;
     ElseIf .RecordCount &amp;lt;&amp;gt; 1 Then&lt;BR /&gt;
          SASLookup = "Not unique. Records = " &amp;amp; .RecordCount&lt;BR /&gt;
     Else&lt;BR /&gt;
          SASLookup = obRecordset.fields("value").Value&lt;BR /&gt;
     End If&lt;BR /&gt;
     .Close&lt;BR /&gt;
End With&lt;BR /&gt;
obConnection.Close&lt;BR /&gt;
End Function</description>
      <pubDate>Tue, 14 Mar 2006 23:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/105#M14</guid>
      <dc:creator>BruceBrad</dc:creator>
      <dc:date>2006-03-14T23:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Reading SAS data into Excel</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/106#M15</link>
      <description>I'm a little confused here - so ignore me if I'm totally off track. But the equivalent of vlookup in Excel is format in SAS. Why not simply format ID to amount, and return the result?

&lt;BR /&gt;
Message was edited by: Pippen at May 22, 2006 7:37 PM&lt;BR /&gt;
Got it the wrong way around!&lt;BR /&gt;</description>
      <pubDate>Mon, 22 May 2006 23:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Reading-SAS-data-into-Excel/m-p/106#M15</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-05-22T23:37:00Z</dc:date>
    </item>
  </channel>
</rss>

