<?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: creating a loop for finding external files or source in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502300#M134071</link>
    <description>Can u help me&lt;BR /&gt;If dataset is not exist in library then it has to sleep for 15minutes&lt;BR /&gt;How to write can u guide me</description>
    <pubDate>Mon, 08 Oct 2018 02:31:13 GMT</pubDate>
    <dc:creator>SRINIVAS_N</dc:creator>
    <dc:date>2018-10-08T02:31:13Z</dc:date>
    <item>
      <title>creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502251#M134051</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can we create a loop for finding external source in a loop .&lt;/P&gt;&lt;P&gt;If source exist --ok&lt;/P&gt;&lt;P&gt;else it has to wait for source 10mins&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EXISTS function is returning false can any one help me&lt;/P&gt;&lt;P&gt;see the attachment for log&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname STPSAMP "/pbr/sfw/sas/940/SASFoundation/9.4/samples/inttech";&lt;BR /&gt;OPTIONS SYMBOLGEN MPRINT MLOGIC;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;SELECT memname INTO:TNAME separated by ' '&lt;BR /&gt;FROM DICTIONARY.TABLES&lt;BR /&gt;WHERE LIBNAME ='STPSAMP';&lt;BR /&gt;QUIT;&lt;BR /&gt;%PUT &amp;amp;TNAME;&lt;/P&gt;&lt;P&gt;%macro checkds;&lt;BR /&gt;%LET one=&amp;amp;TNAME.;&lt;BR /&gt;%let cnt=1;&lt;BR /&gt;%if %sysfunc(exist(STPSAMP.&amp;amp;one.)) %then %do;&lt;BR /&gt;proc print data=sashelp.air;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;data _null_;&lt;BR /&gt;file print;&lt;BR /&gt;put #3 &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145066"&gt;@10&lt;/a&gt; "Data set &amp;amp;dsn. does not exist";&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend checkds;&lt;BR /&gt;%checkds;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Oct 2018 12:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502251#M134051</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-10-07T12:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502274#M134063</link>
      <description>&lt;P&gt;if you look at the log, you'll see that &amp;amp;tname resolves to&amp;nbsp;ODSSTYLE STPBGT STPEURO STPSALE. There are four datasets in the directory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to separate them out - try %scan(&amp;amp;tname, 1, %str( )) to check the existence of the first one.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Oct 2018 19:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502274#M134063</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2018-10-07T19:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502298#M134070</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162184"&gt;@SRINIVAS_N&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;On top of what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt; writes: If your real code also just checks the existence of tables based on a query of dictionary.tables then then code is pretty useless as such a query&amp;nbsp;will only return tables that do exist.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 02:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502298#M134070</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-10-08T02:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502300#M134071</link>
      <description>Can u help me&lt;BR /&gt;If dataset is not exist in library then it has to sleep for 15minutes&lt;BR /&gt;How to write can u guide me</description>
      <pubDate>Mon, 08 Oct 2018 02:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502300#M134071</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-10-08T02:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502302#M134072</link>
      <description>&lt;P&gt;How do you want to call the macro? Do you just pass in a single SAS table per call or do you need to pass in a whole list of SAS tables - or are these SAS tables at all or external files like .csv?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would you create the list of expected tables or files? Could this be something you store in a SAS table to begin with?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 02:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502302#M134072</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-10-08T02:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502303#M134073</link>
      <description>Intially all the tables are in external&lt;BR /&gt;Using libname tables are stored in local location.if dataset are existed no&lt;BR /&gt;problem,if dataset are not there then it has search for dataset for 15mins</description>
      <pubDate>Mon, 08 Oct 2018 02:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502303#M134073</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-10-08T02:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502304#M134074</link>
      <description>&lt;P&gt;Again:&lt;/P&gt;
&lt;P&gt;- Are we looking for the existence of SAS tables or the existence of external files?&lt;/P&gt;
&lt;P&gt;- How is the information stored what's expected?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; - Is that in a table or just in code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; - For how many such tables or files do you have to check?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 02:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502304#M134074</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-10-08T02:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502306#M134076</link>
      <description>&lt;P&gt;May be below will&amp;nbsp;point you into the right direction.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro checkds(dsn,time_to_check_in_sec=900,check_interval_in_sec=30);

  %local startdttm;
  %let startdttm=%sysfunc(datetime());
  %do %while( %sysfunc(sum(%sysfunc(datetime()),-&amp;amp;startdttm))&amp;lt;&amp;amp;time_to_check_in_sec );
    %if %sysfunc(exist(&amp;amp;dsn)) %then
      %do;
        proc print data = &amp;amp;dsn;
        run;
        %goto done;
      %end;
      %put &amp;amp;=startdttm;
      data _null_;
        call sleep(&amp;amp;check_interval_in_sec,1);
        stop;
      run;
  %end;

  data _null_;
    file print;
    put #3 @10 "Data set &amp;amp;dsn. does not exist";
  run;

  %done: ;

%mend checkds;

%checkds(sashelp.class);
%checkds(sashelp.class_not_exist);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could now just call the macro for all the tables you want to check or you can have these tables in a SAS table and then use a data _null_ step with call execute to call the macro once per table in this control table with expected SAS tables.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 03:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502306#M134076</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-10-08T03:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: creating a loop for finding external files or source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502351#M134096</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162184"&gt;@SRINIVAS_N&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Intially all the tables are in external&lt;BR /&gt;Using libname tables are stored in local location.if dataset are existed no&lt;BR /&gt;problem,if dataset are not there then it has search for dataset for 15mins&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;From where do you know the dataset names you are looking for?&lt;/P&gt;
&lt;P&gt;Do you have them in a dataset, or in an external file, or are they fixed and can be hardcoded into the program?&lt;/P&gt;
&lt;P&gt;Or do you want to do something with &lt;EM&gt;any&lt;/EM&gt; dataset that exists in the library, regardless of its name?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 11:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-loop-for-finding-external-files-or-source/m-p/502351#M134096</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-08T11:38:19Z</dc:date>
    </item>
  </channel>
</rss>

