<?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: Suppressing both log and results output during bootstrap: Paper 2424-2018 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/466106#M285274</link>
    <description>&lt;P&gt;Thank you.&amp;nbsp; I will give it a try.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dg&lt;/P&gt;</description>
    <pubDate>Wed, 30 May 2018 15:58:34 GMT</pubDate>
    <dc:creator>dgabriel</dc:creator>
    <dc:date>2018-05-30T15:58:34Z</dc:date>
    <item>
      <title>Suppressing both log and results output during bootstrap: Paper 2424-2018</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/465961#M285272</link>
      <description>&lt;P&gt;Greetings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had success learning and implementing procedures from SAS papers.&amp;nbsp; I am for the first time incorporating a macro for bootstrapping.&amp;nbsp; I am trying to implement the macros in appendix II and III in SAS paper 2424-2018.&amp;nbsp; It was a straight forward cut-and-paste.&amp;nbsp; When I run the program, it prints to the log and output windows with each iteration.&amp;nbsp; But, the final html output is suppressed until the last iteration.&amp;nbsp; However, it only prints the results of the last macro, not the first one.&amp;nbsp; The macros include all the correct things to suppress the output that I have been reading.&amp;nbsp; I have been search Google so long it keeps asking me to verify that I am not a bot.&amp;nbsp; I am not a sophisticated user so I may not even be understanding that I seen the correct answer.&amp;nbsp; Below is my code that includes some of the suggestions that I have seen.&amp;nbsp; &amp;nbsp;The suggestions do suppress log and output windows for the main statistical procedure but not the iterations for the macro.&amp;nbsp; I have 10 iterations so that I can run and try different things to fix this error.&amp;nbsp; I have tried to location of the macro call before and after the macro program itself, not sure if that is an issue.&amp;nbsp; I am using version 9.1 on windows in a dual boot Mac.&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=120 PS=80;
options nosource nonotes;
ods listing close; 
ods html;

Data D1;
INPUT ID visit x y;
DATALINES;

   1.0000000e+00   1.0000000e+00   4.1466014e+01   1.5499570e+01
   1.0000000e+00   2.0000000e+00   8.2491390e+01   1.6625374e+01
   1.0000000e+00   3.0000000e+00   1.1112596e+02   1.7012588e+01
   1.0000000e+00   4.0000000e+00   1.5296788e+02   2.0967996e+01
   1.0000000e+00   5.0000000e+00   1.5126439e+02   2.0436103e+01
   2.0000000e+00   1.0000000e+00   3.6634545e+01   1.4955640e+01
   2.0000000e+00   2.0000000e+00   7.2975351e+01   1.6796694e+01
   2.0000000e+00   3.0000000e+00   1.0506238e+02   2.3160999e+01
   2.0000000e+00   4.0000000e+00   1.3483964e+02   2.1714623e+01
   2.0000000e+00   5.0000000e+00   1.4373045e+02   1.5103717e+01
.......

   4.8000000e+01   1.0000000e+00   4.8610660e+01   1.3193223e+01
   4.8000000e+01   2.0000000e+00   9.5623122e+01   1.5189560e+01
   4.8000000e+01   3.0000000e+00   1.3864495e+02   1.8091522e+01
   4.8000000e+01   4.0000000e+00   1.8578662e+02   2.0179639e+01
   4.8000000e+01   5.0000000e+00   2.5081385e+02   2.1945149e+01
   ;

data data_long (drop=x y i);
	set D1 (keep=ID visit x y);
	array var[2] x y;
	do i =1 to 2;
		vtype =i;
		response = var[i];
		output;
	end;

run;
quit;


title 'Hamlet Paper 198-29';
proc mixed data=data_long method=ml;   
class ID vtype visit;
model response = vtype / solution ddfm=kr;
random vtype / type=un subject=ID v vcorr;
repeated vtype / type=un subject=visit(ID);
*repeated vtype visit/ type=un@ar(1) subject=ID r rcorr;
*repeated vtype visit/ type=un@cs subject=ID r rcorr;
run;
quit;





%MMCorr_BSpvalue(data=D1,ID=ID,rep=visit,var1=x,var2=y,numSamples=10);


%MMCorr_BSCI(data=D1, ID=ID, rep=visit, var1=x, var2=y, numSamples=10);






%macro MMCorr_BSCI(data=,ID=,rep=,var1=,var2=,numSamples=);
/*Select bootstrap samples*/

options nosource nonotes;
ods listing close; 

proc sort data=&amp;amp;data.(keep=&amp;amp;ID.) out=&amp;amp;data._ID nodupkey;
	by &amp;amp;ID.;
run;
proc surveyselect data=&amp;amp;data._ID NOPRINT seed=864132
out=&amp;amp;data._boot(drop=NumberHits)
	method=urs samprate=1 OUTHITS reps=&amp;amp;NumSamples.;
run;
data &amp;amp;data._boot;
	set &amp;amp;data._boot;
	if first.&amp;amp;ID. then RptNum = 1;
	else RptNum + 1;
	by Replicate &amp;amp;ID.;
	ID2 = &amp;amp;ID. || "_" || strip(RptNum);
run;
data &amp;amp;data._boot;
	set &amp;amp;data._boot;
	if first.Replicate then SubjNum = 1;
	else SubjNum + 1;
	by Replicate;
run;

data results;
	input Replicate rho12 convstatus reason $200. rho1 rho2;
run;

/*Bootstrap: Sample Individuals*/
%do j=1 %to &amp;amp;NumSamples.;
	proc sql;
		create table bootsamp
		as select a.*,b.&amp;amp;rep.,b.&amp;amp;var1.,b.&amp;amp;var2.
		from &amp;amp;data._boot a
		left join &amp;amp;data. b
		on &amp;amp;data._boot.ID = &amp;amp;data..ID
		where Replicate = &amp;amp;j.;
quit;
proc sort data=bootsamp;
by &amp;amp;ID. RptNum &amp;amp;rep.;
run;

data &amp;amp;data._long (drop=&amp;amp;var1. &amp;amp;var2. i); *univariate format;
	set bootsamp (keep=&amp;amp;ID. RptNum ID2 &amp;amp;rep. &amp;amp;var1. &amp;amp;var2.);
	if first.ID2 then Visit2 = 1;
	else Visit2 + 1;
	by ID2;
	array var[2] &amp;amp;var1. &amp;amp;var2.;
	do i = 1 to 2;
		Vtype = i;
		Response = var[i];
		output;
		end;
run;

/*Fit Hamlett (2004) mixed model for bootstrap sample*/
proc mixed data=&amp;amp;data._long method=ml;
	class ID2 vtype visit2;
	model response = vtype / solution ddfm=kr;
	random vtype / type=un subject=ID2 v vcorr;
	repeated vtype / type=un subject=visit2(ID2);
	ods output VCorr=VCorr ConvergenceStatus=CS;
run;

/*Calculate correlation*/
proc iml;
	use Vcorr(keep=COL:);
	read all var _ALL_ into Vcorr;
	close Vcorr;

	use CS;
	read all var {Status} into convstatus;
	read all var {Reason} into reason;
	close CS;

	R = Vcorr[1:2,1:2];
	v = cusum( 1 || (ncol(R):2) );
	rho = remove(vech(R), v);
	Replicate = j(2*(2-1)/2,1,&amp;amp;j.);

	create corrcalc var {Replicate rho convstatus reason};
	append;
	close corrcalc;
quit;

data results;
	set results corrcalc;
run;

	dm "output;clear;log;clear;odsresults;select all;clear;";
%end;


data results2;
	set results;
	where convstatus = 0;
run;

data &amp;amp;data._long (drop=&amp;amp;var1. &amp;amp;var2. i); *univariate format;
	set &amp;amp;data. (keep=&amp;amp;ID. &amp;amp;rep. &amp;amp;var1. &amp;amp;var2.);
	array var[2] &amp;amp;var1. &amp;amp;var2.;
	do i = 1 to 2;
		Vtype = i;
		Response = var[i];
		output;
	end;
run;

/*Fit Hamlett (2004) mixed model for original dataset*/
proc mixed data=&amp;amp;data._long method=ml covtest asycov asycorr;
	class &amp;amp;ID. vtype &amp;amp;rep.;
	model response = vtype / solution ddfm=kr;
	random vtype / type=un subject=&amp;amp;ID. v vcorr;
	repeated vtype / type=un subject=&amp;amp;rep.(&amp;amp;ID.);
	ods output CovParms=CovParms;
run;

proc iml;
	use results2;
	read all var {rho} into rho;
	close results2;

	numsamp = nrow(rho);
	use Covparms;
	read all var {Estimate} into Cov_estimate;
	close Covparms;

	a = Cov_estimate[1];
	b = Cov_estimate[2];
	c = Cov_estimate[3];
	g = Cov_estimate[4];
	h = Cov_estimate[5];
	i = Cov_estimate[6];
	rhohat = (b+h)/sqrt((a+g)*(c+i));
	BS_mean = mean(rho);

	z = quantile("Normal",mean(rho &amp;lt; rhohat));
	a = 0;
	qlb = cdf("Normal",z+((z+quantile("Normal",0.025))/(1-a*(z+quantile("Normal",0.025)))));
	qub = cdf("Normal",z+((z+quantile("Normal",0.975))/(1-a*(z+quantile("Normal",0.975)))));

	call qntl(lb,rho,qlb);
	call qntl(ub,rho,qub);

	BootstrapOutput = j(1,4,.);
	BootstrapOutput[,1]=rhohat;
	BootstrapOutput[,2]=BS_mean;
	BootstrapOutput[,3]=lb;
	BootstrapOutput[,4]=ub;
	Outtitle={'Estimate' 'Bootstrap Estimate' '95% CI Lower Bound' '95% CI Upper Bound'};
	Varnames=t("&amp;amp;var1. and &amp;amp;var2.");
	PRINT BootstrapOutput[colname=Outtitle rowname=Varnames];

quit;
%mend MMCorr_BSCI;






%macro MMCorr_BSpvalue(data=,ID=,rep=,var1=,var2=,numSamples=);
/*Select bootstrap samples*/
proc sort data=&amp;amp;data.(keep=&amp;amp;ID.) out=&amp;amp;data._ID nodupkey;
	by &amp;amp;ID.;
run;

proc surveyselect data=&amp;amp;data._ID NOPRINT seed=864132
out=&amp;amp;data._boot(drop=NumberHits)
	method=urs samprate=1 OUTHITS reps=&amp;amp;NumSamples.;
run;
data &amp;amp;data._boot;
	set &amp;amp;data._boot;
	if first.&amp;amp;ID. then RptNum = 1;
	else RptNum + 1;
	by Replicate &amp;amp;ID.;
	ID2 = &amp;amp;ID. || "_" || strip(RptNum);
run;
data &amp;amp;data._boot;
	set &amp;amp;data._boot;
	if first.Replicate then SubjNum = 1;
	else SubjNum + 1;
	by Replicate;
run;

data results;
input Replicate rho convstatus reason $200.;
run;

/*Bootstrap: Sample Individuals*/
%do j=1 %to &amp;amp;NumSamples.;
	proc sql;
		create table bootsamp
		as select a.*,b.&amp;amp;rep.,b.&amp;amp;var1.,b.&amp;amp;var2.
		from &amp;amp;data._boot a
		left join &amp;amp;data. b
		on &amp;amp;data._boot.ID = &amp;amp;data..ID
		where Replicate = &amp;amp;j.;
	quit;

	proc sort data=bootsamp;
		by &amp;amp;ID. RptNum &amp;amp;rep.;
	run;

/*shuffle Wi's within subject, rematch with Ui's form m_i new pairs*/
data w_order;
	set bootsamp (keep=ID2 SubjNum &amp;amp;rep. &amp;amp;var2.);
	order = ranuni(0);
run;
proc sort data=w_order;
	by ID2 order;
run;

/*create line number variable and merge on the line number*/
data bootsamp;
	set bootsamp(drop=&amp;amp;var2.);
	linenum = _n_;
run;
data w_order;
	set w_order(keep=&amp;amp;var2.);
	linenum = _n_;
run;
data bootsamp;
	merge bootsamp w_order;
	by linenum;
run;

data &amp;amp;data._long (drop=&amp;amp;var1. &amp;amp;var2. i); *univariate format;
	set bootsamp (keep=&amp;amp;ID. RptNum ID2 &amp;amp;rep. &amp;amp;var1. &amp;amp;var2.);
	if first.ID2 then Visit2 = 1;
	else Visit2 + 1;
	by ID2;
	array var[2] &amp;amp;var1. &amp;amp;var2.;
	do i = 1 to 2;
		Vtype = i;
		Response = var[i];
		output;
	end;
run;

/*Fit Hamlett (2004) mixed model for bootstrap sample*/
proc mixed data=&amp;amp;data._long method=ml;
	class ID2 vtype visit2;
	model response = vtype / solution ddfm=kr;
	random vtype / type=un subject=ID2 v vcorr;
	repeated vtype / type=un subject=visit2(ID2);
	ods output VCorr=VCorr ConvergenceStatus=CS V=V SolutionF=SolutionF;
run;

/*Calculate correlation for each bootstrap sample*/
proc iml;
	use Vcorr(keep=COL:);
	read all var _ALL_ into Vcorr;
	close Vcorr;

	use V(keep=COL:);
	read all var _ALL_ into VCov;
	close V;
	
	use CS;
	read all var {Status} into convstatus;
	read all var {Reason} into reason;
	close CS;

	use SolutionF;
	read all var {Estimate} into mu;
	close SolutionF;

	R = Vcorr[1:2,1:2];
	v = cusum( 1 || (ncol(R):2) );
	rho = remove(vech(R), v);
 	Replicate = j(2*(2-1)/2,1,&amp;amp;j.);

	create corrcalc var {Replicate rho convstatus reason};
	append;
	close corrcalc;
quit;

data results;
	set results corrcalc;
run;

	dm "output;clear;log;clear;odsresults;select all;clear;";
%end;

data results2;
	set results;
	where convstatus = 0;
run;

data &amp;amp;data._long (drop=&amp;amp;var1. &amp;amp;var2. i); *univariate format;
	set &amp;amp;data. (keep=&amp;amp;ID. &amp;amp;rep. &amp;amp;var1. &amp;amp;var2.);
	array var[2] &amp;amp;var1. &amp;amp;var2.;
	do i = 1 to 2;
		Vtype = i;
		Response = var[i];
		output;
	end;
run;

/*Fit Hamlett (2004) mixed model for original dataset*/
proc mixed data=&amp;amp;data._long method=ml covtest asycov asycorr;
	class &amp;amp;ID. vtype &amp;amp;rep.;
	model response = vtype / solution ddfm=kr;
	random vtype / type=un subject=&amp;amp;ID. v vcorr;
	repeated vtype / type=un subject=&amp;amp;rep.(&amp;amp;ID.);
	ods output CovParms=CovParms;
run;

/*Calculate p-value*/
proc iml;
	use results2;
	read all var {rho} into rho;
	close results2;

	BS_mean = mean(rho);
	numsamp = nrow(rho);

	use Covparms;
	read all var {Estimate} into Cov_estimate;
	close Covparms;

	a = Cov_estimate[1];
	b = Cov_estimate[2];
	c = Cov_estimate[3];
	g = Cov_estimate[4];
	h = Cov_estimate[5];
	i = Cov_estimate[6];
	rhohat = (b+h)/sqrt((a+g)*(c+i));

	if rhohat &amp;gt;0 then p = (sum(rho &amp;lt; 0)+sum(rho &amp;gt; 2*rhohat))/numsamp;
	else p = (sum(rho &amp;gt; 0)+sum(rho &amp;lt; 2*rhohat))/numsamp;

	BootstrapOutput = j(1,3,.);
	BootstrapOutput[,1]=rhohat;
	BootstrapOutput[,2]=BS_mean;
	BootstrapOutput[,3]=p;
	Outtitle={'Estimate' 'Bootstrap Estimate' 'Pvalue'};
	Varnames=t("&amp;amp;var1. and &amp;amp;var2.");
	PRINT BootstrapOutput[colname=Outtitle rowname=Varnames];
quit;
%mend MMCorr_BSpvalue;



&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 11:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/465961#M285272</guid>
      <dc:creator>dgabriel</dc:creator>
      <dc:date>2018-05-30T11:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Suppressing both log and results output during bootstrap: Paper 2424-2018</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/465989#M285273</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;See&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1 class="post-title item fn"&gt;&lt;FONT size="2"&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/05/2" target="_self"&gt;What is the best way to suppress ODS output in SAS?&lt;/A&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;and&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 class="post-title item fn"&gt;&lt;FONT size="2"&gt;&lt;A href="https://blogs.sas.com/content/iml/2013/05/24/turn-off-ods-for-simulations.html" target="_self"&gt;Turn off ODS when running simulations in SAS&lt;/A&gt;&lt;/FONT&gt;&lt;/H1&gt;</description>
      <pubDate>Wed, 30 May 2018 12:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/465989#M285273</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-05-30T12:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Suppressing both log and results output during bootstrap: Paper 2424-2018</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/466106#M285274</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; I will give it a try.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dg&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 15:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/466106#M285274</guid>
      <dc:creator>dgabriel</dc:creator>
      <dc:date>2018-05-30T15:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Suppressing both log and results output during bootstrap: Paper 2424-2018</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/467490#M285275</link>
      <description>&lt;P&gt;I have tried many suggestions including turning off ODS.&amp;nbsp; Printing to the log and output windows are now surpassed.&amp;nbsp; Now, what whatever macros is the last one to run, those are the only results to finally be printed.&amp;nbsp; The results from the previous macro is erased.&amp;nbsp; I contacted the author and was told to rename the last output differently, i.e., bootstrapoutput2.&amp;nbsp; Then go back to the SAS data set and find both outputs.&amp;nbsp; Still only one exists.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dg&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jun 2018 17:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppressing-both-log-and-results-output-during-bootstrap-Paper/m-p/467490#M285275</guid>
      <dc:creator>dgabriel</dc:creator>
      <dc:date>2018-06-04T17:59:46Z</dc:date>
    </item>
  </channel>
</rss>

