<?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 PROC SCAPROC stops recording when I call my macro that runs %SYSFUNC(DOSUBL( in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989146#M380166</link>
    <description>&lt;P&gt;When I call the macro in the source below PROC SCAPROC stops recording and closes the SCA file.&amp;nbsp; I have a simple test step that uses DOSUBL but does not cause the recording to stop.&amp;nbsp; If you are interested in this topic, please run the program below first with&amp;nbsp;&lt;CODE class="language-sas"&gt;%if 0 %then %do; &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;save a copy of SCA file then with&amp;nbsp;&lt;CODE class="language-sas"&gt;%if 1 %then %do;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;and compare the two.&amp;nbsp; You should see that the recording stopped after calling M_EXPAND_VARLIST&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options ls=max mprint=1;
proc scaproc;
   record '.\dosubl-scaproc-bug-2.sca' expandmacros opentimes;
   run;

%macro
   m_expand_varlist /*Returns an expanded variable list and optionally creates an indexed data set of variable names*/
      (
         data  = _LAST_,            /*[R]Input data*/
         var   = _ALL_,             /*[R]Variable List expanded*/
         copy  = &amp;amp;var,              /*[O]Copy &amp;amp;VARS to the OUT= data set*/
         where = 1,                 /*[R]Where clause to subset OUT=, useful for selecting by a name suffix e.g. where=_name_ like '%_Status'*/
         expr  = nliteral(&amp;amp;name),   /*[R]An expression that can be used to modify the names in the expanded list*/
         keep  = ,                  /*[O]Keep data set option for DATA=*/
         drop  = ,                  /*[O]Drop data set option for DATA=*/
         rename= ,                  /*[O]Rename data set option for DATA=*/
         out   = work._deleteme_,   /*[O]Output data indexed by _NAME_ and _INDEX_*/
         name  = _NAME_,            /*[R]Name of the variable name variable in the output data set*/
         label = _LABEL_,           /*[R]Name of the variable label variable in the output data set*/
         index = _INDEX_,           /*[R]Name of the variable index variable in the output data set*/
         dlm   = ' '                /*[R]List delimiter*/
      );
   %local m i;
   %let i=&amp;amp;sysindex;
   %let m=&amp;amp;sysmacroname._&amp;amp;i;
   %do %while(%symexist(&amp;amp;m));
      %let i = %eval(&amp;amp;i + 1);
      %let m=&amp;amp;sysmacroname._&amp;amp;i;
      %end;
   %put NOTE: &amp;amp;=m is a unique symbol name;
   %local rc &amp;amp;m code1 code2 code3 code4 code5;
   %let code1 = %str(options notes=1; proc transpose name=&amp;amp;name label=&amp;amp;label data=&amp;amp;data(obs=0 keep=&amp;amp;keep drop=&amp;amp;drop rename=(&amp;amp;rename)) out=&amp;amp;out(where=(&amp;amp;where)); var &amp;amp;var; copy &amp;amp;copy; run;);
   %let code2 = %str(data &amp;amp;out(index=(&amp;amp;index &amp;amp;name)); set &amp;amp;out; &amp;amp;index+1; run;);
   %let code3 = %str(proc sql noprint; select &amp;amp;expr into :&amp;amp;m separated by &amp;amp;dlm from &amp;amp;out; quit;);
   %if %superq(OUT) eq %str(work._deleteme_) %then %let code4=%str(proc delete data=work._deleteme_; run;);
   %let code5 = %str(options notes=1;run;quit;);
   %let rc=%qsysfunc(dosubl(&amp;amp;code1 &amp;amp;code2 &amp;amp;code3 &amp;amp;code4 &amp;amp;code5));
%unquote(&amp;amp;&amp;amp;&amp;amp;m)
   %mend m_expand_varlist;


data _null_;
   rc = dosubl('%trim(   proc contents data=sashelp.cars varnum; run;)');
   put rc=;
   run;

%if 0 %then %do;   /*Change 0 to 1 to see SCA file that ends after calling M_EXPAND_VARLIST*/
   %global classvars;
   %let classvars=%m_expand_varlist(data=sashelp.classfit,var=_CHARACTER_,out=expand);
   %put NOTE: &amp;amp;=classvars;
   proc print data=expand;
      run;
   %end;

%put _all_;



data shoes shoes2 shoes3;
   set sashelp.shoes;
   run;
proc contents varnum;
   run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2026 13:42:54 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2026-06-03T13:42:54Z</dc:date>
    <item>
      <title>PROC SCAPROC stops recording when I call my macro that runs %SYSFUNC(DOSUBL(</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989146#M380166</link>
      <description>&lt;P&gt;When I call the macro in the source below PROC SCAPROC stops recording and closes the SCA file.&amp;nbsp; I have a simple test step that uses DOSUBL but does not cause the recording to stop.&amp;nbsp; If you are interested in this topic, please run the program below first with&amp;nbsp;&lt;CODE class="language-sas"&gt;%if 0 %then %do; &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;save a copy of SCA file then with&amp;nbsp;&lt;CODE class="language-sas"&gt;%if 1 %then %do;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;and compare the two.&amp;nbsp; You should see that the recording stopped after calling M_EXPAND_VARLIST&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options ls=max mprint=1;
proc scaproc;
   record '.\dosubl-scaproc-bug-2.sca' expandmacros opentimes;
   run;

%macro
   m_expand_varlist /*Returns an expanded variable list and optionally creates an indexed data set of variable names*/
      (
         data  = _LAST_,            /*[R]Input data*/
         var   = _ALL_,             /*[R]Variable List expanded*/
         copy  = &amp;amp;var,              /*[O]Copy &amp;amp;VARS to the OUT= data set*/
         where = 1,                 /*[R]Where clause to subset OUT=, useful for selecting by a name suffix e.g. where=_name_ like '%_Status'*/
         expr  = nliteral(&amp;amp;name),   /*[R]An expression that can be used to modify the names in the expanded list*/
         keep  = ,                  /*[O]Keep data set option for DATA=*/
         drop  = ,                  /*[O]Drop data set option for DATA=*/
         rename= ,                  /*[O]Rename data set option for DATA=*/
         out   = work._deleteme_,   /*[O]Output data indexed by _NAME_ and _INDEX_*/
         name  = _NAME_,            /*[R]Name of the variable name variable in the output data set*/
         label = _LABEL_,           /*[R]Name of the variable label variable in the output data set*/
         index = _INDEX_,           /*[R]Name of the variable index variable in the output data set*/
         dlm   = ' '                /*[R]List delimiter*/
      );
   %local m i;
   %let i=&amp;amp;sysindex;
   %let m=&amp;amp;sysmacroname._&amp;amp;i;
   %do %while(%symexist(&amp;amp;m));
      %let i = %eval(&amp;amp;i + 1);
      %let m=&amp;amp;sysmacroname._&amp;amp;i;
      %end;
   %put NOTE: &amp;amp;=m is a unique symbol name;
   %local rc &amp;amp;m code1 code2 code3 code4 code5;
   %let code1 = %str(options notes=1; proc transpose name=&amp;amp;name label=&amp;amp;label data=&amp;amp;data(obs=0 keep=&amp;amp;keep drop=&amp;amp;drop rename=(&amp;amp;rename)) out=&amp;amp;out(where=(&amp;amp;where)); var &amp;amp;var; copy &amp;amp;copy; run;);
   %let code2 = %str(data &amp;amp;out(index=(&amp;amp;index &amp;amp;name)); set &amp;amp;out; &amp;amp;index+1; run;);
   %let code3 = %str(proc sql noprint; select &amp;amp;expr into :&amp;amp;m separated by &amp;amp;dlm from &amp;amp;out; quit;);
   %if %superq(OUT) eq %str(work._deleteme_) %then %let code4=%str(proc delete data=work._deleteme_; run;);
   %let code5 = %str(options notes=1;run;quit;);
   %let rc=%qsysfunc(dosubl(&amp;amp;code1 &amp;amp;code2 &amp;amp;code3 &amp;amp;code4 &amp;amp;code5));
%unquote(&amp;amp;&amp;amp;&amp;amp;m)
   %mend m_expand_varlist;


data _null_;
   rc = dosubl('%trim(   proc contents data=sashelp.cars varnum; run;)');
   put rc=;
   run;

%if 0 %then %do;   /*Change 0 to 1 to see SCA file that ends after calling M_EXPAND_VARLIST*/
   %global classvars;
   %let classvars=%m_expand_varlist(data=sashelp.classfit,var=_CHARACTER_,out=expand);
   %put NOTE: &amp;amp;=classvars;
   proc print data=expand;
      run;
   %end;

%put _all_;



data shoes shoes2 shoes3;
   set sashelp.shoes;
   run;
proc contents varnum;
   run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2026 13:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989146#M380166</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2026-06-03T13:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SCAPROC stops recording when I call my macro that runs %SYSFUNC(DOSUBL(</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989161#M380168</link>
      <description>&lt;P&gt;Maybe you need a&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc scaproc;
   write;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;... as you can see here:&lt;BR /&gt;Usage Note&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;51875:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;Syntax for using the EXPANDMACROS option with the SCAPROC procedure&lt;BR /&gt;&lt;A href="https://support.sas.com/kb/51/875.html" target="_blank" rel="noopener"&gt;https://support.sas.com/kb/51/875.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Also, if you are in SAS 9.4 windowing environment (display manager), then use program editor instead of enhanced editor:&lt;BR /&gt;Problem Note&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;I&gt;51874:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;The SCAPROC procedure does not expand macros with the EXPANDMACROS option in the Enhanced Editor Window&lt;BR /&gt;&lt;A href="https://support.sas.com/kb/51/874.html" target="_blank"&gt;https://support.sas.com/kb/51/874.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR, Koen&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2026 15:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989161#M380168</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2026-06-03T15:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SCAPROC stops recording when I call my macro that runs %SYSFUNC(DOSUBL(</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989166#M380169</link>
      <description>&lt;P&gt;The issue is that when I run M_EXPAND_VARLIST something is closing the SCA recording&amp;nbsp;&lt;CODE class="language-sas"&gt;JOBSPLIT: END &lt;/CODE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program functions properly it just stops recording.&lt;/P&gt;
&lt;P&gt;This is all run SAS-Batch-Mode&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   rc = dosubl('%trim(   proc contents data=sashelp.cars varnum; run;)');
   put rc=;
   run;

%if 1 %then %do;   /*Change 0 to 1 to see SCA file that ends after calling M_EXPAND_VARLIST*/
   %global classvars;
   %let classvars=%m_expand_varlist(data=sashelp.classfit,var=_CHARACTER_,out=expand);

/* JOBSPLIT: JOBENDTIME 03JUN2026:08:57:57.13 */
/* JOBSPLIT: END */
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jun 2026 16:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989166#M380169</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2026-06-03T16:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SCAPROC stops recording when I call my macro that runs %SYSFUNC(DOSUBL(</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989167#M380170</link>
      <description>&lt;P&gt;I cannot explain that. I'm sorry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If no one else chimes in with a redeeming and saving remark, I would contact Technical Support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Technical Support:&lt;BR /&gt;Here is a link for your convenience: &lt;A href="https://support.sas.com/en/technical-support.html#contact" target="_blank"&gt;https://support.sas.com/en/technical-support.html#contact &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR, Koen&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2026 16:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989167#M380170</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2026-06-03T16:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SCAPROC stops recording when I call my macro that runs %SYSFUNC(DOSUBL(</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989168#M380171</link>
      <description>&lt;P&gt;Try this simplified example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options ls=max mprint=1;
filename record temp;
proc scaproc;
   record record expandmacros opentimes;
run;

data x; x=1; run;

%global classvars;
%let classvars=NAME SEX;
%if 0 %then %do;
%let classvars=%m_expand_varlist(data=sashelp.classfit,var=_CHARACTER_,out=expand);
%end;
%if 1 %then %do;
%let classvars=%sysfunc(dosubl(%nrstr(proc summary data=x;output out=z;run;)));
%end;

%put NOTE: &amp;amp;=classvars;

proc summary data=x ;
  output out=y;
run;

proc scaproc;
 write;
run;

data _null_;
  infile record;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using %SYSFUNC(DOSUBL()) truncates the collection.&lt;/P&gt;
&lt;PRE&gt; 21        /* JOBSPLIT: STEP SOURCE FOLLOWS */ 35
 22         0
 23        data x; x=1; run; 17
 24         0
 25        %global classvars; 18
 26        %let classvars=NAME SEX; 24
 27        %if 0 %then %do; 16
 28        %let classvars=%m_expand_varlist(data=sashelp.classfit,var=_CHARACTER_,out=expand); 83
 29        %end; 5
 30        %if 1 %then %do; 16
 31        %let classvars=%sysfunc(dosubl(%nrstr(proc summary data=x;output out=z;run;))); 79
 32         0
 33        /* JOBSPLIT: JOBENDTIME 03JUN2026:16:06:47.17 */ 48
 34        /* JOBSPLIT: END */ 19&lt;/PRE&gt;
&lt;P&gt;But calling your macro does not truncate, instead it causes it to write gibberish.&lt;/P&gt;
&lt;PRE&gt; 58        /* JOBSPLIT: STEP SOURCE FOLLOWS */ 35
 RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                                                                                                                                                  
 
 59  CHAR  ................0 17
     ZONE  00000000000000003
     NUMR  00000000000000000
 60         0
...
 77        /* JOBSPLIT: STEP SOURCE FOLLOWS */ 35
 
 78  CHAR  ... ...@...a...p�w�D...Pevo....�.�2............��o�D...u.......��o�D...........��o�D...��o�D....... 
     ZONE  0002100400060007F7A470056760000E1A3000000000000CE6B4700700000008E6B470010000000AD6B4700AD6B470010002
     NUMR  000000000001000007F4F00056F0000DF1200000000000007F04F005000000001F04F00100000000FF04F000FF04F0020000
 
      101  ...`...Q...p�w�D...Pevo....�.�2............data x; x=1; 155
     ZONE  100600050007F7A470056760000E1A3000000000000667627327333
     NUMR  00000001000007F4F00056F0000DF12000000000000414108B08D1B
 79         0
 80        /* JOBSPLIT: TASKSTARTTIME 03JUN2026:16:12:39.10 */ 51
...&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2026 16:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SCAPROC-stops-recording-when-I-call-my-macro-that-runs/m-p/989168#M380171</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-06-03T16:14:06Z</dc:date>
    </item>
  </channel>
</rss>

