<?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: How To: Import Using Files Names In Working Folder in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811966#M320335</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/424869"&gt;@blaubner&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, I wasn't specific enough.&lt;/P&gt;
&lt;P&gt;I don't want to designate a library and hard code the actual file names. I want a procedure to be automated. When the program is executed, it would...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. collect the filenames from a directory and put them into work.fakeset under the variable 'fname' (I've achieved this)&lt;/P&gt;
&lt;P&gt;2. The program then brings in all the files from the directory using each 'fname' into one new data set called work.alldata&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that make sense?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;All you need to do is&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;define a LIBNAME for the directory&lt;/LI&gt;
&lt;LI&gt;use all dataset names (without the .sas7bdat extension) in a SET statement&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The list of names can be retrieved from the dataset you created from the directory.&lt;/P&gt;</description>
    <pubDate>Sat, 07 May 2022 16:46:38 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-05-07T16:46:38Z</dc:date>
    <item>
      <title>How To: Import Using Files Names In Working Folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811963#M320332</link>
      <description>&lt;P&gt;Be kind. First time posting...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data fakeset;&lt;BR /&gt;length fref $8 fname $200;&lt;BR /&gt;did = filename(fref,'Fake\Path');&lt;BR /&gt;did = dopen(fref);&lt;BR /&gt;do i = 1 to dnum(did);&lt;BR /&gt;fname = dread(did,i);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;did = dclose(did);&lt;BR /&gt;did = filename(fref);&lt;BR /&gt;keep fname;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...to generate 'fakeset' in my work folder with files from the Fake\Path directory.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All of the files in&amp;nbsp;Fake\Path are in .sas7bdat format. 'fakeset' looks like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;fname&lt;/P&gt;&lt;P&gt;fake1.sas7bdat&lt;/P&gt;&lt;P&gt;fake2.sas7bdat&lt;/P&gt;&lt;P&gt;fake3.sas7bdat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I import each file in&amp;nbsp;Fake\Path using the fname I generated in 'fakeset'? I'd like all of the files imported, then set into one new data set in my work folder.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm going to continue searching for a soltution as I know this has been done before (I'm sure). Thanks for the help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2022 15:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811963#M320332</guid>
      <dc:creator>blaubner</dc:creator>
      <dc:date>2022-05-07T15:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Import Using Files Names In Working Folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811964#M320333</link>
      <description>&lt;P&gt;To be technically precise, you cannot import files that have names ending with .sas7bdat, because they are already SAS data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So all you need is a LIBNAME statement to make the files available to SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mylib 'Fake\Path';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From there, you can combine all of them together using the SET statement in a SAS data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set mylib.fake1 mylib.fake2 mylib.fake3;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 May 2022 16:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811964#M320333</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-07T16:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Import Using Files Names In Working Folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811965#M320334</link>
      <description>&lt;P&gt;Sorry, I wasn't specific enough.&lt;/P&gt;&lt;P&gt;I don't want to designate a library and hard code the actual file names. I want a procedure to be automated. When the program is executed, it would...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. collect the filenames from a directory and put them into work.fakeset under the variable 'fname' (I've achieved this)&lt;/P&gt;&lt;P&gt;2. The program then brings in all the files from the directory using each 'fname' into one new data set called work.alldata&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2022 16:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811965#M320334</guid>
      <dc:creator>blaubner</dc:creator>
      <dc:date>2022-05-07T16:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Import Using Files Names In Working Folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811966#M320335</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/424869"&gt;@blaubner&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, I wasn't specific enough.&lt;/P&gt;
&lt;P&gt;I don't want to designate a library and hard code the actual file names. I want a procedure to be automated. When the program is executed, it would...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. collect the filenames from a directory and put them into work.fakeset under the variable 'fname' (I've achieved this)&lt;/P&gt;
&lt;P&gt;2. The program then brings in all the files from the directory using each 'fname' into one new data set called work.alldata&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that make sense?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;All you need to do is&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;define a LIBNAME for the directory&lt;/LI&gt;
&lt;LI&gt;use all dataset names (without the .sas7bdat extension) in a SET statement&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The list of names can be retrieved from the dataset you created from the directory.&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2022 16:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811966#M320335</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-07T16:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Import Using Files Names In Working Folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811967#M320336</link>
      <description>&lt;P&gt;Sorry I'm not following. If I add a libname to my path, what is the next procedure to read in only the files with a filename from work.&lt;SPAN&gt;fakeset? I don't want to hard code the names myself. I want SAS to do this procedure automatically. I'm assuming a macro needs to be established? I'm not familiar with macros yet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I don't want to do this...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data fakeset;
length fref $8 fname $200;
did = filename(fref,'Fake\Path');
did = dopen(fref);
do i = 1 to dnum(did);
fname = dread(did,i);
output;
end;
did = dclose(did);
did = filename(fref);
keep fname;
run;

libname want 'Fake\Path';&lt;BR /&gt;&lt;BR /&gt;data&amp;nbsp;notwhatiwant;&lt;BR /&gt;set&amp;nbsp;want.fake1&amp;nbsp;want.fake2&amp;nbsp;want.fake3;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2022 17:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811967#M320336</guid>
      <dc:creator>blaubner</dc:creator>
      <dc:date>2022-05-07T17:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: How To: Import Using Files Names In Working Folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811968#M320337</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/424869"&gt;@blaubner&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, I wasn't specific enough.&lt;/P&gt;
&lt;P&gt;I don't want to designate a library and hard code the actual file names. I want a procedure to be automated. When the program is executed, it would...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. collect the filenames from a directory and put them into work.fakeset under the variable 'fname' (I've achieved this)&lt;/P&gt;
&lt;P&gt;2. The program then brings in all the files from the directory using each 'fname' into one new data set called work.alldata&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that make sense?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, let's assume you know the folder name but you don't know the names of the SAS files in the folder ... is that a valid assumption?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mylib 'Fake\Path';
proc sql noprint;
     select distinct cats('mylib.',memname) into :tablenames separated by ' '
        from sashelp.vtable where libname='mylib';
quit;
data want;
     set &amp;amp;tablenames;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2022 21:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-Import-Using-Files-Names-In-Working-Folder/m-p/811968#M320337</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-07T21:45:22Z</dc:date>
    </item>
  </channel>
</rss>

