<?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: proc import inside a data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29539#M5575</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just seen Art297 suggested call execute too - sorry Art!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Jul 2011 13:28:03 GMT</pubDate>
    <dc:creator>DF</dc:creator>
    <dc:date>2011-07-13T13:28:03Z</dc:date>
    <item>
      <title>proc import inside a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29534#M5570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am creating a macro to read a series of .dbf files.&amp;nbsp; I have a dataset that contains the filenames I want to read.&amp;nbsp; Here is the code I am trying:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set infilesPlus;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbfPath = "&amp;amp;directory\" || file;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc import out=value datafile="dbfPath"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbms=dbf replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getdeleted=no;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem I am having is that the proc import function is treating "dbfPath" as a literal string instead of a variable containing a path to a .dbf file.&lt;/P&gt;&lt;P&gt;I have verified that the variable "dbfPath" contains valid paths to files (such as t:\L72mg61\7261G1O.DBF).&amp;nbsp; What is the trick to make "dbfPath"&lt;/P&gt;&lt;P&gt;be recognized as a variable containing a file instead of a string?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 15:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29534#M5570</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-07-12T15:12:10Z</dc:date>
    </item>
    <item>
      <title>proc import inside a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29535#M5571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think you can run a proc, as such, from within a datastep.&amp;nbsp; You could wrap the proc import within a macro and simply call the macro passing dbfPath into it, or use call execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 15:32:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29535#M5571</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-12T15:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc import inside a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29536#M5572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will need to use the data to generate the code for the PROC IMPORT steps.&amp;nbsp; You could use macro language or you could just use the DATA step to generate the code and then %INCLUDE the code.&lt;/P&gt;&lt;P&gt;You will need to import each file to a different dataset otherwise only the last one will exist.&amp;nbsp; You also might want to add code to combine them if they are mulitple instances of the same type of data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename code temp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set infilesPlus;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; file code;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; fileno +1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'proc import dbms=dbf replace out=value' fileno Z3. ' datafile="&amp;amp;directory\' file +(-1) '";'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; / '&amp;nbsp; getdeleted=no;'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; / 'run;'&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%inc code / source2 ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 15:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29536#M5572</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-07-12T15:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc import inside a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29537#M5573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Art told we can't use PROCs inside DATA Step. But here is one possible solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;DATA _NULL_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; SET DSN END=EOF;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; CALL SYMPUT('FILE'||LEFT(_N_),"&amp;amp;directory"||DBFILE);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; IF EOF THEN CALL SYMPUT('NUM',_N_);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;%MACRO IMPORT;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; %DO I=1 %TO &amp;amp;NUM;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROC IMPORT OUT=DSN&amp;amp;I.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; DATAFILE=&amp;amp;&amp;amp;FILE&amp;amp;I.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;DBMS=DBF REPLACE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; %END;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;%MEND IMPORT;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt;%IMPORT;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; color: #0000ff; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Hope this helps.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Dhanasekaran R&amp;nbsp; &lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jul 2011 08:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29537#M5573</guid>
      <dc:creator>dhana</dc:creator>
      <dc:date>2011-07-13T08:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc import inside a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29538#M5574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;It might be worth trying the approaches outlined here if possible: &lt;/SPAN&gt;&lt;A _jive_internal="true" href="https://communities.sas.com/thread/30161"&gt;http://communities.sas.com/thread/30161&lt;/A&gt;&lt;SPAN&gt; - KSharp and Null give examples of importing multiple files using a single data step.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can't adapt that, then perhaps you could use Call Execute to run each version of proc import after your data step completes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example (not tested), something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set infilesPlus;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbfPath = "&amp;amp;directory\" || file;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc import out=' &amp;amp; trim(value) &amp;amp; ' datafile="' &amp;amp; trim(dbfPath) &amp;amp; '" dbms=dbf replace;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getdeleted=no;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: DF&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jul 2011 13:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29538#M5574</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-07-13T13:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: proc import inside a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29539#M5575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just seen Art297 suggested call execute too - sorry Art!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jul 2011 13:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-import-inside-a-data-step/m-p/29539#M5575</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-07-13T13:28:03Z</dc:date>
    </item>
  </channel>
</rss>

