<?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 Extract dataset name from expression (datasetname(options)). in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-dataset-name-from-expression-datasetname-options/m-p/974260#M377855</link>
    <description>&lt;P&gt;Is there any method, where I can extract dataset name from expressions like:&lt;/P&gt;&lt;P&gt;&amp;lt;work.ds(...where=(...))&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ds(... where=(...))&amp;gt;&lt;/P&gt;&lt;P&gt;or somehow check that this expression is valid in macro calls (wthout PROC or DATA statements)?&lt;/P&gt;</description>
    <pubDate>Fri, 05 Sep 2025 15:27:29 GMT</pubDate>
    <dc:creator>TimurShangareev</dc:creator>
    <dc:date>2025-09-05T15:27:29Z</dc:date>
    <item>
      <title>Extract dataset name from expression (datasetname(options)).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-dataset-name-from-expression-datasetname-options/m-p/974260#M377855</link>
      <description>&lt;P&gt;Is there any method, where I can extract dataset name from expressions like:&lt;/P&gt;&lt;P&gt;&amp;lt;work.ds(...where=(...))&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ds(... where=(...))&amp;gt;&lt;/P&gt;&lt;P&gt;or somehow check that this expression is valid in macro calls (wthout PROC or DATA statements)?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 15:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-dataset-name-from-expression-datasetname-options/m-p/974260#M377855</guid>
      <dc:creator>TimurShangareev</dc:creator>
      <dc:date>2025-09-05T15:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract dataset name from expression (datasetname(options)).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-dataset-name-from-expression-datasetname-options/m-p/974273#M377862</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409409"&gt;@TimurShangareev&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there any method, where I can extract dataset name from expressions like:&lt;/P&gt;
&lt;P&gt;&amp;lt;work.ds(...where=(...))&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;ds(... where=(...))&amp;gt;&lt;/P&gt;
&lt;P&gt;or somehow check that this expression is valid in macro calls (wthout PROC or DATA statements)?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Let me make sure I am understanding. You have some text, like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SASHELP.CLASS(where=(sex='F'))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and you want to determine the data set name (which is SASHELP.CLASS). Is that what you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where do you want to do this? (In a SAS data step? Somewhere else?)&lt;/P&gt;
&lt;P&gt;What is the source of the input text string?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 16:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-dataset-name-from-expression-datasetname-options/m-p/974273#M377862</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-09-05T16:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extract dataset name from expression (datasetname(options)).</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-dataset-name-from-expression-datasetname-options/m-p/974277#M377864</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409409"&gt;@TimurShangareev&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there any method, where I can extract dataset name from expressions like:&lt;/P&gt;
&lt;P&gt;&amp;lt;work.ds(...where=(...))&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;ds(... where=(...))&amp;gt;&lt;/P&gt;
&lt;P&gt;or somehow check that this expression is valid in macro calls (wthout PROC or DATA statements)?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It would help if you explained in more detail what you actually mean. Perhaps some example use cases would help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mentioned macro calls.&amp;nbsp; So in macro code here are a couple of simple things.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsn=sashelp.class(where=(age&amp;gt;11));
%let valid=FALSE;
%let dsid=%sysfunc(open(&amp;amp;dsn));
%if &amp;amp;dsid %then %do;
  %let valid=TRUE;
  %let dsid=%sysfunc(close(&amp;amp;dsid));
%end;
%let name_only=%scan(&amp;amp;dsn,1,());
%let options=%substr(&amp;amp;dsn%str( ),%length(&amp;amp;name_only)+1);
%let memname=%scan(&amp;amp;name_only,-1,.);
%let libref=%scan(WORK.&amp;amp;name_only,-2,.);
%put &amp;amp;=dsn &amp;amp;=valid ;
%put &amp;amp;=name_only &amp;amp;=options;
%put &amp;amp;=libref &amp;amp;=memname ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Sep 2025 17:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-dataset-name-from-expression-datasetname-options/m-p/974277#M377864</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-05T17:14:52Z</dc:date>
    </item>
  </channel>
</rss>

