<?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: Autogenerate Work Library table name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956177#M373398</link>
    <description>&lt;P&gt;I don't understand ... why would a data step behave differently when being part of a macro?&lt;/P&gt;
&lt;P&gt;The '&lt;STRONG&gt;_data_&lt;/STRONG&gt;' works identically outside and within a macro, no?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers, Koen&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jan 2025 11:24:28 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2025-01-15T11:24:28Z</dc:date>
    <item>
      <title>Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956170#M373393</link>
      <description>&lt;P&gt;Hi to all and Happy new year!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One question: I have noticed that when I am using the "_data_" keyword in a data step, SAS automatically creates a name for the dataset.&lt;/P&gt;
&lt;P&gt;How do I invoke the same command using macro programming, to control which dataset name (and dataset of course) is generated?&lt;/P&gt;
&lt;P&gt;I want this functionality because in the end of the process flow (EG), I need to clean any data resources that I don't want to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Vasilios&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 09:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956170#M373393</guid>
      <dc:creator>vfarmak</dc:creator>
      <dc:date>2025-01-15T09:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956172#M373395</link>
      <description>&lt;P&gt;If you are creating data sets in the WORK library by default all data sets in&amp;nbsp; the Work library are cleared when the SAS session ends. So I don't see what name you want to reference. They&amp;nbsp; would also be named Work.dataN where N is an integer. You could explicitly remove all of them using&lt;/P&gt;
&lt;PRE&gt;Proc datasets library=work;
   delete data: ;
run;
quit;&lt;/PRE&gt;
&lt;P&gt;So there is no need to "know" the exact names created. The colon after the Data means "delete all data sets whose name starts with "data".&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 10:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956172#M373395</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-01-15T10:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956173#M373396</link>
      <description>&lt;P&gt;So you want to be able do delete all tables with the naming convention DATA&lt;EM&gt;n&lt;/EM&gt;?&lt;/P&gt;
&lt;P&gt;If you can stick to data steps in your macro it should work, or?&lt;/P&gt;
&lt;P&gt;Otherwise you could have macro variable which you augment each time you create a new table. Depends on how your macro(s) are designed.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 10:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956173#M373396</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-01-15T10:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956175#M373397</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;They would also be named Work.dataN where N is an integer. You could explicitly remove all of them using&lt;/P&gt;
&lt;PRE&gt;Proc datasets library=work;
   delete data: ;
run;
quit;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note that this code will delete all data sets starting with DATA, such as DATA_FINAL_PLEASE_SAVE_ME, not just data sets named DATA&lt;EM&gt;n.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 11:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956175#M373397</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2025-01-15T11:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956177#M373398</link>
      <description>&lt;P&gt;I don't understand ... why would a data step behave differently when being part of a macro?&lt;/P&gt;
&lt;P&gt;The '&lt;STRONG&gt;_data_&lt;/STRONG&gt;' works identically outside and within a macro, no?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers, Koen&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 11:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956177#M373398</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2025-01-15T11:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956187#M373401</link>
      <description>&lt;P&gt;I want the SAS code to be a part of a SAS macro and combine in with fork and wait functionality provided in SAS Data Integration Studio.&lt;/P&gt;
&lt;P&gt;If I have the same process running for lets say many records simultaneously, I don't one process to read or write to datasets of another process.&lt;/P&gt;
&lt;P&gt;This is the main reason I want to have autogenerated names just like the drag and drop functionality in DI (when you actually drag an drop an extract component, the name of the table is a random string).&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 13:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956187#M373401</guid>
      <dc:creator>vfarmak</dc:creator>
      <dc:date>2025-01-15T13:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956188#M373402</link>
      <description>&lt;P&gt;I tried to use the _data_ keyword in a let statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let random_ds = _data_;&lt;/PRE&gt;
&lt;P&gt;But this does not work.&lt;/P&gt;
&lt;P&gt;I haven't though tried to use it with sysfunc. I will give it a try&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 13:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956188#M373402</guid>
      <dc:creator>vfarmak</dc:creator>
      <dc:date>2025-01-15T13:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956204#M373406</link>
      <description>&lt;P&gt;How do you mean it doesn't work?&lt;/P&gt;
&lt;P&gt;If you use that macro variable in a data step, it should work, no?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can share some of your macro code so we can see your logic.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 15:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956204#M373406</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-01-15T15:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956220#M373409</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/309333"&gt;@vfarmak&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried to use the _data_ keyword in a let statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let random_ds = _data_;&lt;/PRE&gt;
&lt;P&gt;But this does not work.&lt;/P&gt;
&lt;P&gt;I haven't though tried to use it with sysfunc. I will give it a try&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That will set the macro variable to the 6 character string _data_.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What did you WANT it to set the macro variable to?&lt;/P&gt;
&lt;P&gt;Why not just let SAS determine the name and then use &amp;amp;SYSLAST?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data; run;
%let random_ds = &amp;amp;syslast ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the names are not RANDOM.&amp;nbsp; They are SEQUENTIAL.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    data; run;

NOTE: The data set WORK.DATA1 has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds


2    %let random_ds = &amp;amp;syslast ;
3    %put &amp;amp;=random_ds;
RANDOM_DS=WORK.DATA1
4    data; run;

NOTE: The data set WORK.DATA2 has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


5    %let random_ds = &amp;amp;syslast ;
6    %put &amp;amp;=random_ds;
RANDOM_DS=WORK.DATA2

&lt;/PRE&gt;
&lt;P&gt;So if you want to generate sequential names just make your own counter variable.&lt;/P&gt;
&lt;PRE&gt;1    %let next_seq=1;
2    %let myprefix=pathA;
3
4    %let random_ds = &amp;amp;myprefix.&amp;amp;next_seq;
5    %let next_seq=%eval(&amp;amp;next_seq+1);
6    %put &amp;amp;=random_ds;
RANDOM_DS=pathA1
7
8    %let random_ds = &amp;amp;myprefix.&amp;amp;next_seq;
9    %let next_seq=%eval(&amp;amp;next_seq+1);
10   %put &amp;amp;=random_ds;
RANDOM_DS=pathA2
&lt;/PRE&gt;
&lt;P&gt;Then each of your parallel tracks can use their own prefix and avoid any dataset name conflicts.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 16:42:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956220#M373409</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-15T16:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956866#M373578</link>
      <description>&lt;P&gt;Exactly. Only the ones that I have defined (or the macro code defined).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 11:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956866#M373578</guid>
      <dc:creator>vfarmak</dc:creator>
      <dc:date>2025-01-22T11:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956867#M373579</link>
      <description>&lt;P&gt;I want to mimic the functionality that DI gives when you drag and drop an extract components which has an output table with a generated name.&lt;/P&gt;
&lt;P&gt;I can see that your code provides this kind of functionality.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using the below statements you have mentioned, might be the case and I will definitely give it a try.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ;
run;
%let ds = &amp;amp;syslast;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jan 2025 12:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956867#M373579</guid>
      <dc:creator>vfarmak</dc:creator>
      <dc:date>2025-01-22T12:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate Work Library table name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956868#M373580</link>
      <description>&lt;P&gt;I want to mimic the functionality that DI gives when you drag and drop an extract components which has an output table with a generated name.&lt;/P&gt;
&lt;P&gt;I can see that your code provides this kind of functionality.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using the below statements you have mentioned, might be the case and I will definitely give it a try.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data; run;
%let ds = &amp;amp;syslast;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jan 2025 12:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Autogenerate-Work-Library-table-name/m-p/956868#M373580</guid>
      <dc:creator>vfarmak</dc:creator>
      <dc:date>2025-01-22T12:01:04Z</dc:date>
    </item>
  </channel>
</rss>

