<?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: Applying a macro to all datasets in a library. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799249#M314254</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm trying to apply a macro to all datasets in a library without have to list the names of all datasets. The output should be a .xlsx file where the tabs are labelled according to the names of the datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"C:\data\" contain the following datasets:&lt;/P&gt;
&lt;P&gt;ds001.sas&lt;BR /&gt;ds002.sas&lt;BR /&gt;ds003.sas&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Something is really wrong here. Datasets have the extensions sas7bdat, files ending with "sas" are files containing sas-code, accessing those files by using a libname statement is not possible.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2022 05:52:20 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-03-01T05:52:20Z</dc:date>
    <item>
      <title>Applying a macro to all datasets in a library.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799248#M314253</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to apply a macro to all datasets in a library without have to list the names of all datasets.&amp;nbsp; The output should be a .xlsx file where the tabs are labelled according to the names of the datasets.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"C:\data\" contain the following datasets:&lt;/P&gt;&lt;P&gt;ds001.sas&lt;BR /&gt;ds002.sas&lt;BR /&gt;ds003.sas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let study=903001;

libname f&amp;amp;study. "C:\data\" inencoding=any;

%let rundate = %SYSFUNC(today(),yymmddd10.);

goptions device=actximg;

ods _all_ close;

ods excel file="C:\output\&amp;amp;study._listing_&amp;amp;rundate..xlsx"

style=excel;

%macro safelist(dsin);

ods excel options 
	(flow='tables' 
	autofilter='on' 
	frozen_headers='on' 
	sheet_name= "&amp;amp;dsin");
proc report data=f&amp;amp;study..&amp;amp;dsin. 
	split='\' 
	style(column)={fontfamily='Malgun Gothic Semilight' 
	fontsize=1 vjust=t} 
	style(header)={fontfamily='Malgun Gothic Semilight' 
	fontsize=1 
	just=l 
	vjust=t 
	background=#00FFFF};
run;

%mend;

 %safelist (dsin=f&amp;amp;study.);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The error message in the log is this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;1090        %safelist (dsin=f&amp;amp;study.);
ERROR: File F903001.F903001.DATA does not exist.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If I use:&lt;BR /&gt;%safelist (ds001);&lt;BR /&gt;%safelist (ds002);&lt;BR /&gt;%safelist (ds003);&lt;BR /&gt;it works. I'm trying to avoid having to list all datasets in a library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 04:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799248#M314253</guid>
      <dc:creator>mandonium</dc:creator>
      <dc:date>2022-03-01T04:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Applying a macro to all datasets in a library.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799249#M314254</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm trying to apply a macro to all datasets in a library without have to list the names of all datasets. The output should be a .xlsx file where the tabs are labelled according to the names of the datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"C:\data\" contain the following datasets:&lt;/P&gt;
&lt;P&gt;ds001.sas&lt;BR /&gt;ds002.sas&lt;BR /&gt;ds003.sas&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Something is really wrong here. Datasets have the extensions sas7bdat, files ending with "sas" are files containing sas-code, accessing those files by using a libname statement is not possible.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 05:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799249#M314254</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-03-01T05:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Applying a macro to all datasets in a library.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799262#M314265</link>
      <description>&lt;P&gt;Your macro expects a single level&amp;nbsp;&lt;EM&gt;dataset name&lt;/EM&gt; (without library) as parameter, so you cannot use a library reference there.&lt;/P&gt;
&lt;P&gt;You need to call your macro for every dataset within your source library, and you can do that from SASHELP.VTABLE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set sashelp.vtable;
where libname = upcase("f&amp;amp;study.");
call execute('%nrstr(%safelist(' !! strip(memname) !! '))');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Mar 2022 09:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799262#M314265</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-01T09:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Applying a macro to all datasets in a library.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799266#M314268</link>
      <description>Sorry, datasets should read&lt;BR /&gt;ds001.sas7bdat&lt;BR /&gt;ds002.sas7bdat&lt;BR /&gt;ds003.sas7bdat</description>
      <pubDate>Tue, 01 Mar 2022 09:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-a-macro-to-all-datasets-in-a-library/m-p/799266#M314268</guid>
      <dc:creator>mandonium</dc:creator>
      <dc:date>2022-03-01T09:28:03Z</dc:date>
    </item>
  </channel>
</rss>

