<?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 data set using files with the same name in many directories in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160196#M31182</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bruce: If you run the first two lines of code from your window's command prompt, it will create the list of files:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cd c:\&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;dir dec30.sas7bdat /s /b &amp;gt; c:\temp\temp.txt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The following datastep will create all of the libnames:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data temp (keep=lname path);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "c:\temp\temp.txt";&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length lname $8;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length path $150;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x=find(_infile_,"\",-200);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lname=catt('xx',_n_);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; path=substr(_infile_,1,x-1);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ecmd=cat("libname ",strip(lname),'"',strip(path),'";');&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(ecmd);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The following proc sql call will create a macro variable that will contain the string that can be used to set all of the files:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql noprint;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; select lname||".dec30"&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :dpaths&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; separated by " "&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from temp&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Finally, the following step will concatenate all of the files together. The only part I can't help you with, since I don't have 9.2, is regarding what will be returned with the indsname option. &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; set &amp;amp;dpaths. indsname=dsn;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Feb 2015 00:40:56 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2015-02-12T00:40:56Z</dc:date>
    <item>
      <title>Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160186#M31172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data set, call it myds.sas7bdat . I have a two-level directory structure /location/date , and each location/date subdirectory (e.g. ACY/Dec 30) has a myds data set in it. I would like to merge all these data sets. In addition, &lt;SPAN style="font-size: 13.3333330154419px;"&gt;since there's no location info in the files, &lt;/SPAN&gt;I'd like to add a location variable during the merge. Can anyone suggest a way to do this? Macro or data step programming is fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks much, Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 20:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160186#M31172</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2015-02-09T20:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160187#M31173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What operating system are you on and which version of SAS are you using?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 20:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160187#M31173</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-02-09T20:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160188#M31174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Windows 7 and SAS 9.2 . thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 20:50:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160188#M31174</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2015-02-09T20:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160189#M31175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First, confirm that these are all SAS data sets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 22:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160189#M31175</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-09T22:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160190#M31176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bruce,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I dont have SAS 9.2, thus can only provide a partial solution. The following will get all of the files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will likely have to create and apply a format to convert the libname paths to their physical names, as well as strip the dsn the get the paths and apply the format to them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x "cd c:\";&lt;/P&gt;&lt;P&gt;x "dir dec30.sas7bdat /s /b &amp;gt; c:\temp\temp.txt";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp (keep=lname path);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "c:\temp\temp.txt";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length lname $8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length path $150;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x=find(_infile_,"\",-200);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lname=catt('xx',_n_);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; path=substr(_infile_,1,x-1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ecmd=cat("libname ",strip(lname),'"',strip(path),'";');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(ecmd);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select lname||".dec30"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :dpaths&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from temp&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set &amp;amp;dpaths. indsname=dsn;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 22:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160190#M31176</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-02-09T22:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160191#M31177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can ask DOS to generate the list of file names for you.&lt;/P&gt;&lt;P&gt;You can reference the dataset by using the file's name in quotes in a SET statement.&lt;/P&gt;&lt;P&gt;You can use the INDSNAME option to make the name available to your data step so that you can parse out the directory names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let path=c:\downloads ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data files ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; infile "dir /b/s &amp;amp;path\*.sas7bdat" pipe truncover ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input fname $256.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select quote(trim(fname)) into :flist separated by ' '&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from files&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; length dsname $256 folder memname $32 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; set &amp;amp;flist indsname=dsname ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; folder = scan(dsname,-2,'\.') ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; memname = scan(dsname,-1,'\.');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 01:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160191#M31177</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-10T01:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160192#M31178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the suggestion. When I run the first part of the code (data files ...), I get an error message: ERROR: Insufficient authorization to access PIPE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea how to correct this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again, Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 14:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160192#M31178</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2015-02-10T14:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160193#M31179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your site admins have turned off the ability to call operating system commands from within SAS.&lt;/P&gt;&lt;P&gt;You could run the DOS command in another window and save the output and then just read the output as a simple text file.&lt;/P&gt;&lt;P&gt;Or you could use SAS functions to open the directory and retrieve the file names. &lt;/P&gt;&lt;P&gt;For example look at this old thread.&amp;nbsp; &lt;A __default_attr="205166" __jive_macro_name="message" class="jive_macro jive_macro_message active_link" href="https://communities.sas.com/" modifiedtitle="true" title="Re: Read Files in A Directory"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also look at this paper that has a nice program for recursively reading the names of the files in a directory.&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.wuss.org/proceedings12/55.pdf" title="http://www.wuss.org/proceedings12/55.pdf"&gt;http://www.wuss.org/proceedings12/55.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 03:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160193#M31179</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-11T03:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160194#M31180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for the suggestions. I'll try one (or more) and report here if one works. I think I like the paper.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 21:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160194#M31180</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2015-02-11T21:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160195#M31181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Arthur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your suggestion. Sorry I did not respond earlier, but I did not see it. I think I can use part of your code, especially the simple use of DOS commands to create a file list and the SAS code beginning with ecmd. Can you please tell me what that line and the next line do? Ultimately, I want to merge a bunch of datasets with the same name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll post a solution once I have one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again, Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 00:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160195#M31181</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2015-02-12T00:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160196#M31182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bruce: If you run the first two lines of code from your window's command prompt, it will create the list of files:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cd c:\&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;dir dec30.sas7bdat /s /b &amp;gt; c:\temp\temp.txt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The following datastep will create all of the libnames:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data temp (keep=lname path);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "c:\temp\temp.txt";&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length lname $8;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length path $150;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x=find(_infile_,"\",-200);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lname=catt('xx',_n_);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; path=substr(_infile_,1,x-1);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ecmd=cat("libname ",strip(lname),'"',strip(path),'";');&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(ecmd);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The following proc sql call will create a macro variable that will contain the string that can be used to set all of the files:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql noprint;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; select lname||".dec30"&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :dpaths&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; separated by " "&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from temp&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Finally, the following step will concatenate all of the files together. The only part I can't help you with, since I don't have 9.2, is regarding what will be returned with the indsname option. &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; set &amp;amp;dpaths. indsname=dsn;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 00:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160196#M31182</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-02-12T00:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160197#M31183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Arthur,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much for sharing your knowledge and time. As soon as I've had a chance to run the code, I'll flag your response with Correct Answer. Looking forward to using this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again, Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 12:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160197#M31183</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2015-02-12T12:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160198#M31184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Take another look at the suggestion from&amp;nbsp; &lt;A __default_attr="2431" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/" modifiedtitle="true" title="Tom "&gt;&lt;/A&gt;dated F&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px; background-color: #ffffff;"&gt;eb 9, 2015 7:22 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 13:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160198#M31184</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-02-12T13:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160199#M31185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I saw that solution and tried it. The PIPE command (or option) is disabled on my system, unfortunately, and it may not be simple to enable it. I think elements of that solution overlap with others, so I hope to use parts of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 13:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160199#M31185</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2015-02-12T13:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160200#M31186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;:smileyshocked:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the reply to your complaint about PIPE &lt;A __default_attr="2431" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/" modifiedtitle="true" title="Tom "&gt;&lt;/A&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;told you how to fix it.&amp;nbsp; You have to create the path list as a file before you run SAS.&amp;nbsp; This nice part of using the path as the "data set name" is that INDSNAME then contains the path so you can create the origin variable you need directly.&amp;nbsp; No need for all those macro variables and LIBREFS.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 13:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160200#M31186</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-02-12T13:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160201#M31187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bruce: I agree with data_null_ that Tom's code is definitely better than what I had suggested and should be the one you mark as being correct. I didn't realize that SAS now allows full paths in a set statement and their use definitely simplifies identifying the directory names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the same approach I mentioned in my last post, i&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; line-height: 1.5em; background-color: #ffffff;"&gt;f you run the first two lines of code, below, from your window's command prompt, it will create the list of files:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cd c:\&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;dir dec30.sas7bdat /s /b &amp;gt; c:\temp\temp.txt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The following datastep will create a file containing all of the desired files and paths&lt;SPAN style="line-height: 1.5em;"&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;data files ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile "c:\temp\temp.txt" truncover ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input fname $256.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The following proc sql call will create a macro variable that will contain the string that can be used to set all of the files:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select quote(trim(fname)) into :flist separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from files&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Finally, the following step will concatenate all of the files together including variables that indicate the filenames and their full paths&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data want ;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp; length dsname $256 folder memname $32 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set &amp;amp;flist indsname=dsname ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; folder = scan(dsname,-2,'\.') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; memname = scan(dsname,-1,'\.');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 16:05:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160201#M31187</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-02-12T16:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set using files with the same name in many directories</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160202#M31188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code Tom sent is mostly working.&amp;nbsp; In the last step I get an error message because the same variable is a character in some files and numeric in others. I know how to fix that for individual files, but would like to fix all the files using a macro. The first two files listed in the &amp;amp;flist macro variable are the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"\\VNTSCEX.LOCAL\DFS\SPECIAL\SAS-STORAGE\WILSON, BRUCE\WINTERWX\SAMPLE DATA\ACY\Dec &lt;/P&gt;&lt;P&gt;23\acy12232014_fund.sas7bdat" "\\VNTSCEX.LOCAL\DFS\SPECIAL\SAS-STORAGE\WILSON, BRUCE\WINTERWX\SAMPLE &lt;/P&gt;&lt;P&gt;DATA\ACY\Dec 24\acy12242014_fund.sas7bdat" "\\VNTSCEX.LOCAL\DFS\SPECIAL\SAS-STORAGE\WILSON, &lt;/P&gt;&lt;P&gt;BRUCE\WINTERWX\SAMPLE DATA\ACY\Dec 25\acy12252014_fund.sas7bdat" &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please tell me how to iterate over &amp;amp;flist so that I can open each data set, repair it (I can handle that part), and save it was a new, cleaner data set, named something like acy_12232014_fund_clean (i.e., I just append something to the original name).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much, Bruce &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2015 16:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-using-files-with-the-same-name-in-many/m-p/160202#M31188</guid>
      <dc:creator>brucehughw</dc:creator>
      <dc:date>2015-02-24T16:48:16Z</dc:date>
    </item>
  </channel>
</rss>

