<?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 extract a file from any location into a dataset in sas EG in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640026#M190516</link>
    <description>&lt;P&gt;You will have to write a data-step reading the file. I recommend starting with one file, which name to provide in the infile-statement, without any steps automatically selecting the file. The input-statement depends on the structure of the file.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 08:14:17 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-04-15T08:14:17Z</dc:date>
    <item>
      <title>How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639961#M190459</link>
      <description>&lt;P&gt;Hi community, my yesterday's question was a bit confusing actually it was for me too.&lt;/P&gt;
&lt;P&gt;Now I have to a extract the latest file from a location and store it to a dataset.&lt;/P&gt;
&lt;P&gt;suppose I have a input folder location "/sas/sasdataset/lev1/" and in that location there are multiple .txt files e.g. user20200414.txt, user20200415.txt, Userxyz.txt are present, I have to extract the latest or any of the&amp;nbsp; file into a dataset. How can I do? Please if anybody a code example.&lt;/P&gt;
&lt;P&gt;I am using below code for the latest file but the observations in variable date is null in the output of this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;/filename users pipe "/sas/sasdata/Lev1/External_Files/Cofunds_Files/mi/";&lt;BR /&gt;data files;&lt;BR /&gt;infile users truncover;&lt;BR /&gt;input filename $100.;&lt;BR /&gt;date = input(scan(scan(scan(filename,-1,'/'),1,'.'),3,'_'), mmddyy8.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort data=files;&lt;BR /&gt;by descending date;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set files;&lt;BR /&gt;call symput('infile',filename);&lt;BR /&gt;stop;&lt;BR /&gt;run;/&amp;gt;&lt;/P&gt;
&lt;P&gt;Now if I get the latest how can I extract it into dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDITED&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 06:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639961#M190459</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T06:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639979#M190474</link>
      <description>&lt;P&gt;Try to be as clear and precise with your questions.&lt;/P&gt;
&lt;P&gt;What do you mean by "latest"? Is it the file with the most recent modification timestamp, does it have a timestamp coded into the filename (if yes, how?), or do you have a data item in the file itself (e. g. in a header) that defines a point in time?&lt;/P&gt;
&lt;P&gt;Your directory name suggests a UNIX system for your SAS server. Is this true?&lt;/P&gt;
&lt;P&gt;Do you have XCMD enabled? Run&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc options option=xcmd;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to determine that.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 06:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639979#M190474</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-15T06:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639986#M190481</link>
      <description>suppose there are files like user20200415.txt, user20200414.txt, Userxyx.txt how can I extract any of this files and convert it into a dataset?</description>
      <pubDate>Wed, 15 Apr 2020 06:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639986#M190481</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T06:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639992#M190487</link>
      <description>&lt;P&gt;See this example code for retrieving all the filenames in a directory (tested on SAS University Edition):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files;
length location $8;
rc = filename(location,"/folders/myfolders");
did = dopen(location);
do i = 1 to dnum(did);
  name = dread(did,i);
  output;
end;
rc = dclose(did);
rc = filename(location);
keep name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639992#M190487</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-15T07:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639996#M190491</link>
      <description>Thanks this is working and my first part of the problem is solved, now how can I convert "any" one  of the file from that location in dataset after extracting those files</description>
      <pubDate>Wed, 15 Apr 2020 07:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639996#M190491</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T07:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639997#M190492</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316738"&gt;@annypanny&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;suppose there are files like user20200415.txt, user20200414.txt, Userxyx.txt how can I extract any of this files and convert it into a dataset?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have to repeat what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; already asked for: "Try to be as clear and precise with your questions."&lt;/P&gt;
&lt;P&gt;So, do you want to import all files or just the latest? If you want to import all files: are all files in the same structure? If yes: do you want one dataset per file or one dataset with the contents of all files?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/639997#M190492</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-04-15T07:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640007#M190501</link>
      <description>yes, and all are in same structure e.g., ONLINEUSER20200415.txt, ONLINEUSER20200414.txt how can I find the latest one and How can I extract any one of them into a dataset (say example of file which is also latest according to date ONLINEUSER20200415.txt)</description>
      <pubDate>Wed, 15 Apr 2020 07:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640007#M190501</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T07:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640018#M190509</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640018#M190509</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T07:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640026#M190516</link>
      <description>&lt;P&gt;You will have to write a data-step reading the file. I recommend starting with one file, which name to provide in the infile-statement, without any steps automatically selecting the file. The input-statement depends on the structure of the file.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 08:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640026#M190516</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-04-15T08:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a file from any location into a dataset in sas EG</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640031#M190519</link>
      <description>please would you mind to answer on the given link  as it is more clear question then my previous ones:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-external-file-into-a-sas-dataset/td-p/640024" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-external-file-into-a-sas-dataset/td-p/640024&lt;/A&gt;</description>
      <pubDate>Wed, 15 Apr 2020 08:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-a-file-from-any-location-into-a-dataset-in-sas-EG/m-p/640031#M190519</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T08:20:19Z</dc:date>
    </item>
  </channel>
</rss>

