<?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: Pick up sas dataset name automatically from folder in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20907#M3319</link>
    <description>Thanks Peter.&lt;BR /&gt;
&lt;BR /&gt;
This works great...&lt;BR /&gt;
&lt;BR /&gt;
Jig.</description>
    <pubDate>Tue, 27 May 2008 21:01:53 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-05-27T21:01:53Z</dc:date>
    <item>
      <title>Pick up sas dataset name automatically from folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20904#M3316</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I have a project to do where I have an excel spreadsheet which has ID and one more column of data. I can create a sas dataset from excel spreadsheet which will have 2 variables by importing from excel to sas. I have more than 50 sas datasets in one folder. I have to add this column to all the sas datasets. I can merge the column using ID number. I can write a merge data step macro like below:&lt;BR /&gt;
&lt;BR /&gt;
%macro jig (name= );&lt;BR /&gt;
&lt;BR /&gt;
data datdir.NEW_&amp;amp;name ;&lt;BR /&gt;
    merge excelsheetdata datdir.&amp;amp;name ;&lt;BR /&gt;
    by ID;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%mend jig;&lt;BR /&gt;
&lt;BR /&gt;
%jig (name=AB);&lt;BR /&gt;
%jig (name=AC); and so on for 50+ times..........................&lt;BR /&gt;
&lt;BR /&gt;
I have to write these datasets name manually. Is there any programming flexibility in SAS where SAS code can pick up these dataset names directly from the folder  where these datasets are located rather than me passing 50+ names manually in a macro call.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
&lt;BR /&gt;
Jig.</description>
      <pubDate>Fri, 23 May 2008 21:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20904#M3316</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-23T21:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Pick up sas dataset name automatically from folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20905#M3317</link>
      <description>Sure, SAS supports the use of wildcards in file and directory names.&lt;BR /&gt;
&lt;BR /&gt;
You will need to read the SAS documentation.&lt;BR /&gt;
&lt;BR /&gt;
An alternative is to write a macro that creates a list of files in a dataset, which can then be used for subsequent processing.  This can be done the "dopen" function and subsequent "d..." functions.&lt;BR /&gt;
&lt;BR /&gt;
If you need the explicit filename used, in a datastep, when reading the EXCEL spreadsheet, then you can use the "filevar=" option.</description>
      <pubDate>Mon, 26 May 2008 15:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20905#M3317</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-26T15:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pick up sas dataset name automatically from folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20906#M3318</link>
      <description>Hi Jigar&lt;BR /&gt;
&lt;BR /&gt;
as I understand it, your NAME= parameter is one of many SAS data sets in a folder. That folder needs to be assigned as a SAS library, like [pre] libname jig 'that folder' ;[/pre]Then with the internal SAS dictionary.table you can use the names of the SAS data sets in that JIG library as a variable. Try :[pre]&lt;BR /&gt;
 %macro jig( name );&lt;BR /&gt;
    data jig.NEW_&amp;amp;name ;&lt;BR /&gt;
       merge excelsheetdata datdir.&amp;amp;name ;&lt;BR /&gt;
          by ID ;&lt;BR /&gt;
    run ;&lt;BR /&gt;
 %mend jig;&lt;BR /&gt;
  &lt;BR /&gt;
 *invoke macro JIG for each data set in JIG library;&lt;BR /&gt;
  * 1 create table of data set names in library JIG ;&lt;BR /&gt;
  proc sql ;&lt;BR /&gt;
      create table jigsDs as select memname from sashelp.vtable&lt;BR /&gt;
         where libname='JIG' and nobs GT 0 ;&lt;BR /&gt;
  quit;&lt;BR /&gt;
  * 2 use that data set to invoke the macro once for each DS ;&lt;BR /&gt;
  data _null_ ;&lt;BR /&gt;
    set jigsDS ;&lt;BR /&gt;
    call execute( '%nrstr( %%)' !! 'jig(' !! memname !! ') ' ) ;&lt;BR /&gt;
  run;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
try that.&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 27 May 2008 15:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20906#M3318</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-27T15:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Pick up sas dataset name automatically from folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20907#M3319</link>
      <description>Thanks Peter.&lt;BR /&gt;
&lt;BR /&gt;
This works great...&lt;BR /&gt;
&lt;BR /&gt;
Jig.</description>
      <pubDate>Tue, 27 May 2008 21:01:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pick-up-sas-dataset-name-automatically-from-folder/m-p/20907#M3319</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-27T21:01:53Z</dc:date>
    </item>
  </channel>
</rss>

