<?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 do I create a dataset from a dynamic set statment? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/594213#M34829</link>
    <description>&lt;P&gt;Thanks, this will do the trick.&amp;nbsp; Yes, batching from 283 to 1, then appending singles everyday after with chron.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Oct 2019 20:01:03 GMT</pubDate>
    <dc:creator>JGx</dc:creator>
    <dc:date>2019-10-04T20:01:03Z</dc:date>
    <item>
      <title>How do I create a dataset from a dynamic set statment?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/593750#M34795</link>
      <description>&lt;P&gt;EG&amp;nbsp;7.13&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to generate a single data set from many.&amp;nbsp; Each dataset has the same format, structure.&amp;nbsp;&amp;nbsp; To do this I envision a data statement that calls a macro which sets my data from a concatenated files list using a date range.&amp;nbsp; Like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/*CREATE FILE LIST*/
%MACRO file_part (startdate=, enddate=);

DATA file_list (DROP=date);
   DO date= "&amp;amp;startdate"d TO"&amp;amp;enddate"d;
   FORMAT date yymmddn8.;
   file_part = cats("/mydir/",put(date,yymmddn8.),"_report");
      OUTPUT;
   END;
   
RUN;
%MEND;

/*Line of code for testing file_part as standalone*/
/*%FILE_PART(startdate=01Jan2019, enddate=1Oct2019);*/

/*GET MY DATA*/
DATA mydata;
SET %file_part(startdate=01Jan2019, enddate=10Oct2019);
RUN;&lt;BR /&gt;&lt;BR /&gt;ERROR: File WORK.DATA.DATA does not exist.&lt;BR /&gt;ERROR: The variable date in the DROP, KEEP, or RENAME list has never been referenced.&lt;/PRE&gt;&lt;P&gt;My research leads me to believe the DO statement in file_part is in correct, but I can't pintpoint why.&amp;nbsp; How can I fix the code above to return the expected results (one dataset set from many)?&amp;nbsp;&amp;nbsp; Errors in code block.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 17:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/593750#M34795</guid>
      <dc:creator>JGx</dc:creator>
      <dc:date>2019-10-03T17:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a dataset from a dynamic set statment?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/593767#M34796</link>
      <description>&lt;P&gt;It looks like you're reading from a text file. Do you need to limit the dates or do you need to read all files.&lt;/P&gt;
&lt;P&gt;SAS allows wildcards/filelists so reading multiple files at once is trivial.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI - you cannot use SET with text files, you need to first convert them to a SAS data set format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293559"&gt;@JGx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;EG&amp;nbsp;7.13&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to generate a single data set from many.&amp;nbsp; Each dataset has the same format, structure.&amp;nbsp;&amp;nbsp; To do this I envision a data statement that calls a macro which sets my data from a concatenated files list using a date range.&amp;nbsp; Like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/*CREATE FILE LIST*/
%MACRO file_part (startdate=, enddate=);

DATA file_list (DROP=date);
   DO date= "&amp;amp;startdate"d TO"&amp;amp;enddate"d;
   FORMAT date yymmddn8.;
   file_part = cats("/mydir/",put(date,yymmddn8.),"_report.txt");
      OUTPUT;
   END;
   
RUN;
%MEND;

/*Line of code for testing file_part as standalone*/
/*%FILE_PART(startdate=01Jan2019, enddate=1Oct2019);*/

/*GET MY DATA*/
DATA mydata;
SET %file_part(startdate=01Jan2019, enddate=10Oct2019);
RUN;&lt;BR /&gt;&lt;BR /&gt;ERROR: File WORK.DATA.DATA does not exist.&lt;BR /&gt;ERROR: The variable date in the DROP, KEEP, or RENAME list has never been referenced.&lt;/PRE&gt;
&lt;P&gt;My research leads me to believe the DO statement in file_part is in correct, but I can't pintpoint why.&amp;nbsp; How can I fix the code above to return the expected results (one dataset set from many)?&amp;nbsp;&amp;nbsp; Errors in code block.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 15:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/593767#M34796</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-03T15:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a dataset from a dynamic set statment?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/593837#M34797</link>
      <description>&lt;P&gt;Thanks Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, no, the files are all SAS datasets.&amp;nbsp; I removed '.txt' from the OP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I need to maintain integrity of the data range within the macro parameters.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 18:01:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/593837#M34797</guid>
      <dc:creator>JGx</dc:creator>
      <dc:date>2019-10-03T18:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a dataset from a dynamic set statment?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/593843#M34798</link>
      <description>&lt;P&gt;When the macro processor runs the macro it passes the generate text back to SAS to run.&lt;/P&gt;
&lt;P&gt;So your are trying to run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SET DATA file_list (DROP=date);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which is why you get the message about WORK.DATA not existing.&amp;nbsp; You must have previously run the macro and generated the dataset named FILE_LIST, but since your didn't keep the variable DATE you are getting an error when trying to drop it on the way into this data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just pull the list of names out the dataset.&amp;nbsp; How many names is it going to be? Will the whole list fit into a single macro variable (maximum of 65K bytes)?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%FILE_PART(startdate=01Jan2019, enddate=1Oct2019);

proc sql noprint;
  select quote(trim(file_part)) into :dslist separated by ' '
  from file_part
  ;
quit;

/*GET MY DATA*/
DATA mydata;
  SET &amp;amp;dslist ;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If not then modify the macro to only generate the list of names instead of generating SAS code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO file_part (startdate=, enddate=);
%local date ;
%do date= %sysevalf("&amp;amp;startdate"d) %to %sysevalf("&amp;amp;enddate"d);
   "/mydir/%sysfunc(putn(&amp;amp;date,yymmddn8.))_report"
%end;
%MEND;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can use it in the middle of another statement if you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA mydata;
  SET %file_part(startdate=01Jan2019, enddate=10Oct2019);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Note: Do you really want combine 283 separate datasets?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 18:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/593843#M34798</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-03T18:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a dataset from a dynamic set statment?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/594213#M34829</link>
      <description>&lt;P&gt;Thanks, this will do the trick.&amp;nbsp; Yes, batching from 283 to 1, then appending singles everyday after with chron.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 20:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-create-a-dataset-from-a-dynamic-set-statment/m-p/594213#M34829</guid>
      <dc:creator>JGx</dc:creator>
      <dc:date>2019-10-04T20:01:03Z</dc:date>
    </item>
  </channel>
</rss>

