<?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: Finding the name of a dataset whilst in the datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-name-of-a-dataset-whilst-in-the-datastep/m-p/523081#M142080</link>
    <description>&lt;P&gt;Use the automatic macro variable SYSPROCNAME.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
%if &amp;amp;sysprocname=DATASTEP %then %put Running in Data step ;
%else %put NOT in data step;
%mend test;

data a;
 set sashelp.class ;
 %test;
run;

proc sql ;
 %test;
quit;

%test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS. Your sample code is garbled as it has the macro definition AFTER the macro call.&amp;nbsp; On top of that it has the macro definition in the middle of a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Dec 2018 15:28:37 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-12-21T15:28:37Z</dc:date>
    <item>
      <title>Finding the name of a dataset whilst in the datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-name-of-a-dataset-whilst-in-the-datastep/m-p/523080#M142079</link>
      <description>&lt;P&gt;I have a piece of code that I want to use, possibly inside and outside of data steps. In order to use "DOSUBL" I need to check whether I'm inside a data step or not. I know it doesn't sound great, but just bare with me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried SYSLAST etc but it doesn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test1;
  set test;

%com(blah blah blah);
      %macro com /parmbuff;

***WOULD LIKE TO INSERT CODE HERE TO CHECK IF I'M INSIDE DATASTEP****
         rc = %sysfunc(dosubl(
          *extra code*
         ));
        %mend com;
run;&lt;/PRE&gt;&lt;P&gt;I've tried changing it to macro code such as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test1;
  set test;

%com(blah blah blah);
      %macro com /parmbuff;

         %let rc = %sysfunc(dosubl(
          *extra code*
         ));
        %mend com;
run;&lt;/PRE&gt;&lt;P&gt;But constantly got the errors:&lt;/P&gt;&lt;P&gt;NOTE: One or more missing close parentheses have been supplied for the %DOSUBL function.&lt;BR /&gt;ERROR: Expected close parenthesis after macro function invocation not found.&lt;/P&gt;&lt;P&gt;&amp;amp; yes i did have the same amount of open brackets as i did closed. It should be noted that inside the *extra code section* I have data steps, let statements, macro do's etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wondering if anyone knows of any functions that would help me do this. I was thinking if there was something to check if last data step was closed or something. I'm a bit unsure what I'm looking for, so open to suggestions.&lt;/P&gt;&lt;P&gt;(Please don't ask me why its confusing and will sound silly to anyone not working on it)&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-name-of-a-dataset-whilst-in-the-datastep/m-p/523080#M142079</guid>
      <dc:creator>leannemcn13</dc:creator>
      <dc:date>2018-12-21T15:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the name of a dataset whilst in the datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-name-of-a-dataset-whilst-in-the-datastep/m-p/523081#M142080</link>
      <description>&lt;P&gt;Use the automatic macro variable SYSPROCNAME.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
%if &amp;amp;sysprocname=DATASTEP %then %put Running in Data step ;
%else %put NOT in data step;
%mend test;

data a;
 set sashelp.class ;
 %test;
run;

proc sql ;
 %test;
quit;

%test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS. Your sample code is garbled as it has the macro definition AFTER the macro call.&amp;nbsp; On top of that it has the macro definition in the middle of a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-name-of-a-dataset-whilst-in-the-datastep/m-p/523081#M142080</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-21T15:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the name of a dataset whilst in the datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-name-of-a-dataset-whilst-in-the-datastep/m-p/523082#M142081</link>
      <description>&lt;P&gt;Yes, this is not my actual code- that was private, hence the "blah blah blah". I just wanted to give you a quick example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Either way that has worked, thank you so much! I can now finish for Christmas break Happy as Larry.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-name-of-a-dataset-whilst-in-the-datastep/m-p/523082#M142081</guid>
      <dc:creator>leannemcn13</dc:creator>
      <dc:date>2018-12-21T15:48:15Z</dc:date>
    </item>
  </channel>
</rss>

