<?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 Timing problem with call execute, proc sql, &amp;amp;sqlobs and a %do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Timing-problem-with-call-execute-proc-sql-amp-sqlobs-and-a-do/m-p/681571#M206175</link>
    <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having what seems to be timing problems with the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname config xlsx "&amp;amp;tfl_output_path_2\config.xlsx" access=readonly;

data _null_;
	set config.graphpad;
	call execute(macro || '(input_dataset=' || dataset || ', day_bin_variable=' || day_bin_variable || ', day_bin_variable_format=' || day_bin_variable_format || ',where=' || condition ||', output=&amp;amp;tfl_output_path_2\' || output || additional_parameters || ')');
run;

libname config clear;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The macros causing issues look like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro export_for_graphpad_fi(input_dataset=,
			subject_variable=,
			result_variable=,
			day_variable=,
			day_bin_variable=,
			day_bin_variable_format=,
			where=,
			output=);

	proc sql noprint;
		create table data_with_dose as
			select d.DOSE,
				r.*
			from &amp;amp;input_dataset r
				left join cohort_dose_map d
					on r.XGROUP EQ d.XGROUP
					and r.XCOHORT EQ d.XCOHORT
				where not missing(r.XCOHORT) %if %length(&amp;amp;where) GT 0 %then and &amp;amp;where;;
		select distinct XGROUP
			into :xgroup1-:xgroup10
				from &amp;amp;input_dataset;
	run;

	%do i = 1 %to &amp;amp;sqlobs;
		ods excel file="&amp;amp;output._%lowcase(%sysfunc(translate(&amp;amp;&amp;amp;xgroup&amp;amp;i, _, %str( )))).xlsx"
			options(sheet_name="data" flow="tables");

		proc report data=data_with_dose split="\" missing;
			where XGROUP EQ "&amp;amp;&amp;amp;xgroup&amp;amp;i";
			columns &amp;amp;day_bin_variable DOSE, (GM UCLGM LCLGM);
			define &amp;amp;day_bin_variable / " " group exclusive preloadfmt format=&amp;amp;day_bin_variable_format order=data;
			define DOSE / " " across;
			define GM / " " group;
			define UCLGM / " " group;
			define LCLGM / " " group;
		run;

		ods excel close;
	%end;

	proc datasets noprint;
		delete data_with_dose;
	run;

%mend export_for_graphpad_fi;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The first time I run the code after starting a new SAS session I am getting a warning stating that &amp;amp;sqlobs is not defined. It appears that there are some timing issues between call execute, proc sql and when the &amp;amp;sqlobs variable is getting defined. How can I work them around? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ETA: if we ignore call execute it appears that using &amp;amp;sqlobs with %do loops is supported:&amp;nbsp;&lt;A href="https://www.mwsug.org/proceedings/2009/how/MWSUG-2009-H01.pdf," target="_blank"&gt;https://www.mwsug.org/proceedings/2009/how/MWSUG-2009-H01.pdf,&lt;/A&gt;&amp;nbsp;page 6.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Sep 2020 09:26:01 GMT</pubDate>
    <dc:creator>js5</dc:creator>
    <dc:date>2020-09-04T09:26:01Z</dc:date>
    <item>
      <title>Timing problem with call execute, proc sql, &amp;sqlobs and a %do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timing-problem-with-call-execute-proc-sql-amp-sqlobs-and-a-do/m-p/681571#M206175</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having what seems to be timing problems with the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname config xlsx "&amp;amp;tfl_output_path_2\config.xlsx" access=readonly;

data _null_;
	set config.graphpad;
	call execute(macro || '(input_dataset=' || dataset || ', day_bin_variable=' || day_bin_variable || ', day_bin_variable_format=' || day_bin_variable_format || ',where=' || condition ||', output=&amp;amp;tfl_output_path_2\' || output || additional_parameters || ')');
run;

libname config clear;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The macros causing issues look like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro export_for_graphpad_fi(input_dataset=,
			subject_variable=,
			result_variable=,
			day_variable=,
			day_bin_variable=,
			day_bin_variable_format=,
			where=,
			output=);

	proc sql noprint;
		create table data_with_dose as
			select d.DOSE,
				r.*
			from &amp;amp;input_dataset r
				left join cohort_dose_map d
					on r.XGROUP EQ d.XGROUP
					and r.XCOHORT EQ d.XCOHORT
				where not missing(r.XCOHORT) %if %length(&amp;amp;where) GT 0 %then and &amp;amp;where;;
		select distinct XGROUP
			into :xgroup1-:xgroup10
				from &amp;amp;input_dataset;
	run;

	%do i = 1 %to &amp;amp;sqlobs;
		ods excel file="&amp;amp;output._%lowcase(%sysfunc(translate(&amp;amp;&amp;amp;xgroup&amp;amp;i, _, %str( )))).xlsx"
			options(sheet_name="data" flow="tables");

		proc report data=data_with_dose split="\" missing;
			where XGROUP EQ "&amp;amp;&amp;amp;xgroup&amp;amp;i";
			columns &amp;amp;day_bin_variable DOSE, (GM UCLGM LCLGM);
			define &amp;amp;day_bin_variable / " " group exclusive preloadfmt format=&amp;amp;day_bin_variable_format order=data;
			define DOSE / " " across;
			define GM / " " group;
			define UCLGM / " " group;
			define LCLGM / " " group;
		run;

		ods excel close;
	%end;

	proc datasets noprint;
		delete data_with_dose;
	run;

%mend export_for_graphpad_fi;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The first time I run the code after starting a new SAS session I am getting a warning stating that &amp;amp;sqlobs is not defined. It appears that there are some timing issues between call execute, proc sql and when the &amp;amp;sqlobs variable is getting defined. How can I work them around? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ETA: if we ignore call execute it appears that using &amp;amp;sqlobs with %do loops is supported:&amp;nbsp;&lt;A href="https://www.mwsug.org/proceedings/2009/how/MWSUG-2009-H01.pdf," target="_blank"&gt;https://www.mwsug.org/proceedings/2009/how/MWSUG-2009-H01.pdf,&lt;/A&gt;&amp;nbsp;page 6.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 09:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timing-problem-with-call-execute-proc-sql-amp-sqlobs-and-a-do/m-p/681571#M206175</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2020-09-04T09:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Timing problem with call execute, proc sql, &amp;sqlobs and a %do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Timing-problem-with-call-execute-proc-sql-amp-sqlobs-and-a-do/m-p/681577#M206178</link>
      <description>Looks like %nrstr is the solution:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/sgf/2017/08/02/call-execute-for-sas-data-driven-programming/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2017/08/02/call-execute-for-sas-data-driven-programming/&lt;/A&gt;</description>
      <pubDate>Fri, 04 Sep 2020 09:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Timing-problem-with-call-execute-proc-sql-amp-sqlobs-and-a-do/m-p/681577#M206178</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2020-09-04T09:59:01Z</dc:date>
    </item>
  </channel>
</rss>

