<?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 the sas dataset from the given path in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302243#M64093</link>
    <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;&lt;P&gt;good morning!!!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;libname raju 'C:\Users\q807540\Documents\SAS';&lt;BR /&gt;ds=adverse;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data adv;&lt;BR /&gt;set raju.&amp;amp;ds;&lt;BR /&gt;where sex = 'M';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;now&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if the adverse SAS dataset present in the mentioned path then excel output should open with the output.(I am writing proc export step in the final.)&lt;/P&gt;&lt;P&gt;if the adverse dataset not present in the mentioned path then excel output should open saying "NO SAS DATASET PRESENT".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Raju&lt;/P&gt;</description>
    <pubDate>Tue, 04 Oct 2016 04:52:30 GMT</pubDate>
    <dc:creator>Raj_C</dc:creator>
    <dc:date>2016-10-04T04:52:30Z</dc:date>
    <item>
      <title>reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302243#M64093</link>
      <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;&lt;P&gt;good morning!!!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;libname raju 'C:\Users\q807540\Documents\SAS';&lt;BR /&gt;ds=adverse;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data adv;&lt;BR /&gt;set raju.&amp;amp;ds;&lt;BR /&gt;where sex = 'M';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;now&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if the adverse SAS dataset present in the mentioned path then excel output should open with the output.(I am writing proc export step in the final.)&lt;/P&gt;&lt;P&gt;if the adverse dataset not present in the mentioned path then excel output should open saying "NO SAS DATASET PRESENT".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Raju&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 04:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302243#M64093</guid>
      <dc:creator>Raj_C</dc:creator>
      <dc:date>2016-10-04T04:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302246#M64095</link>
      <description>&lt;PRE&gt;
You could write a macro.

%if %sysfunc(exist(work.adverse)) %then %do;
 data ad;
  set work.adverse;
 run;
%else %do;
 data ad;
  msg="Table not found."
 run;
%end;


&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Oct 2016 05:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302246#M64095</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-04T05:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302251#M64097</link>
      <description>&lt;P&gt;You can use MACRO to achieve it;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname raju 'C:\Users\q807540\Documents\SAS';&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;%let&lt;/FONT&gt; ds=adverse;&amp;nbsp;&amp;lt;I&lt;EM&gt;&amp;nbsp;found that you are omitting the "%let"&amp;gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO test;&lt;BR /&gt;%if %sysfunc(exist(raju.&amp;amp;ds)) %then %do;&lt;BR /&gt;data ad;&lt;/P&gt;&lt;P&gt;set raju.&amp;amp;ds;&lt;/P&gt;&lt;P&gt;where sex = 'M';&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%else %do;&lt;BR /&gt;data ad;&lt;BR /&gt;msg="NO SAS DATASET PRESENT";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%MEND test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Test;&lt;/P&gt;&lt;P&gt;--------------------------------------------&lt;/P&gt;&lt;P&gt;You can also use %put function to make your message displaying in the SAS log instead of in&amp;nbsp;a dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put NO SAS DATASET PRESENT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just replace&amp;nbsp;the code between %else %do; and %end;&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>Tue, 04 Oct 2016 05:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302251#M64097</guid>
      <dc:creator>terrencetang</dc:creator>
      <dc:date>2016-10-04T05:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302281#M64107</link>
      <description>&lt;P&gt;Why is it that you do not know what data you have?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 08:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302281#M64107</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-04T08:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302497#M64168</link>
      <description>&lt;P&gt;Can we give multiple datasets inplace of work.adverse ?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 01:15:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302497#M64168</guid>
      <dc:creator>Raj_C</dc:creator>
      <dc:date>2016-10-05T01:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302503#M64172</link>
      <description>&lt;PRE&gt;

I don't understand what you mean.
If you want check multiple datasets, you can check dictionary table like :

select * from dictionary.members ;


&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Oct 2016 02:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302503#M64172</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-05T02:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302825#M64285</link>
      <description>I mean to say if I am using multiple datasets I'm muy programs like adverse, conmeds, and ipdmin.&lt;BR /&gt;These I will define like this&lt;BR /&gt;DS 1 = adverse&lt;BR /&gt;DS 2 = conmeds&lt;BR /&gt;DS 3 = ipdmin&lt;BR /&gt;&lt;BR /&gt;In this scenario how to proceed.&lt;BR /&gt;&lt;BR /&gt;Here also if three datasets present then it should look for the code otherwise else if condition it should check.</description>
      <pubDate>Thu, 06 Oct 2016 02:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302825#M64285</guid>
      <dc:creator>Raj_C</dc:creator>
      <dc:date>2016-10-06T02:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302827#M64286</link>
      <description>&lt;PRE&gt;
CALL EXECUTE()


%macro xxx(dsn=,..........)
.......
%mend;


data _null_;
 input dsn : $40.;
 call execute('%xxx(dsn='||dsn||', .........  ) ');
cards;
adverse
conmeds
idpad
;
run;



&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Oct 2016 03:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302827#M64286</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-06T03:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302831#M64287</link>
      <description>Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 06 Oct 2016 03:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302831#M64287</guid>
      <dc:creator>Raj_C</dc:creator>
      <dc:date>2016-10-06T03:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302833#M64288</link>
      <description>&lt;PRE&gt;
You mean check the three tables at the same time ?


%macro xx(library=sashelp,dsn=air cars class);
%local n m;
%let m=%sysfunc(countw(&amp;amp;dsn));
%let _dsn="%sysfunc(prxchange(s/\s+/" "/,-1,&amp;amp;dsn))";

 proc sql noprint;
  select count(*) into : n
   from dictionary.members
    where libname=upcase("&amp;amp;library") and memname in (%upcase(&amp;amp;_dsn));
 quit;

%if &amp;amp;n=&amp;amp;m %then %put WARNING: Yes. ;
 %else %put WARNING: No. ;

%mend;

%xx(library=sashelp,dsn=air cars c)

%xx(library=sashelp,dsn=air cars class)

&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Oct 2016 03:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302833#M64288</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-06T03:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: reading the sas dataset from the given path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302869#M64298</link>
      <description>&lt;P&gt;Well, if you don't know what data you have, then your going to have an uphill struggle anyways. &amp;nbsp;But to check this, why bother with all the macro nonsense making harder to read/maintain/debug code when you can simply:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  call symputx("adverse",exist(work.adverse));
  call symputx("conmeds",exist(work.conmeds));
  call symputx("ipdmin",exist(work.ipdmin));
run;
&lt;/PRE&gt;
&lt;P&gt;Or just execute your code conditionally:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="WORK" and memname in ("ADVERSE","CONMEDS","IPDMIN")));
  if memname="ADVERSE" then call execute('%adverse_macro();');
  if memname="CONMEDS" then call execute('%conmeds_macro();');
  if memname="IPDMIN" then call execute('%ipdmin_macro();');
run;
&lt;/PRE&gt;
&lt;P&gt;Or, far better to fix the problem at source, i.e create three empty datasets called adverse, conmeds, ipdmin, and then append any data you get to them. &amp;nbsp;The data always exists then even if there are no observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2016 08:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-the-sas-dataset-from-the-given-path/m-p/302869#M64298</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-06T08:29:39Z</dc:date>
    </item>
  </channel>
</rss>

