BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
H
Pyrite | Level 9 H
Pyrite | Level 9

Hello,

I am using the BY statement in PROC QUANTREG along with ODS OUTPUT in order to generate a dataset with all of the listed quantile estimates for all of the models. The below code does this for just one of the models, instead of all ten which is desired. Further below is the code for a reproducible example.  Any suggestions would be appreciated.

 

proc quantreg ci=sparsity/iid algorithm=interior(tolerance=1.e-4) 
                 data=table alpha=0.01;
      model diff_6 =  /
                     quantile= 0.05 to 0.95 by 0.15
                     plot=quantplot;
	ods output   ParameterEstimates  = Estimates;
run;

 

 

Reproducible full code, there are some elements still included in the data creation step that aren't relevant to the inquiry, but these variables should be apparent.

%let N = 20;
%let Numsamples = 10;
data Table1 (keep=Baseline Xc_3 sampleID);
	call streaminit(4321);

	p0 = 1.00;
	p1 = 0.60; p2 = 0.20; p3 = 0.10; p4 = 0.05; p5 = 0.03; p6 = 01; p7 = 0.01; p8 = 0.0; 
	do sampleID = 1 to &numsamples;
		do i = 1 to &N;
			Baseline = rand("Table1", p0);
			Xc_3 = rand("Table1", p1, p2, p3, p4, p5, p6, p7, p8);
			output;
		end;
	end;
run;
data Table2 (keep=Xc_6);
	call streaminit(432109);

	p1 = 0.60; p2 = 0.20; p3 = 0.10; p4 = 0.05; p5 = 0.03; p6 = 01; p7 = 0.01; p8 = 0.0; 

	do sampleID = 1 to &numsamples;
		do i = 1 to &N;
			Xc_6 = rand("Table1", p1, p2, p3, p4, p5, p6, p7, p8);
			output;
		end;
	end;
run;

data Table3 (keep=Xnc_3);
	call streaminit(43927);

	p1 = 0.80; p2 = 0.13; p3 = 0.05;  p4=0.02; 

	do sampleID = 1 to &numsamples;
		do i = 1 to &N;
			Xnc_3 = rand("Table3", p1, p2, p3, p4);
			output;
		end;
	end;
run;

data Table4 (keep=Xnc_6);
	call streaminit(43215);

	p1 = 0.80; p2 = 0.13; p3 = 0.05;  p4=0.02; 

	do sampleID = 1 to &numsamples;
		do i = 1 to &N;
			Xnc_6 = rand("Table3", p1, p2, p3, p4);
			output;
		end;
	end;
run;

data Table;
	merge Table1-Table4;
run;


data Table;
	set Table;
	Baseline = Baseline + 19;
	Xc_3 = Xc_3-1;
	Xc_6 = Xc_6-1;
	Xc_6t = Xc_3 + Xc_6;

	Xnc_3  = Xnc_3-1;
	Xnc_6  = Xnc_6-1;
	Xnc_6t = Xnc_3 + Xnc_6;

	diff_3 = Xc_3 - Xnc_3;
	diff_6 = Xc_6t - Xnc_6t;
run;

proc freq data=table;
	tables 	(Baseline 
			Xc_3 
			Xc_6 
			Xc_6t

			Xnc_3 
			Xnc_6 
			Xnc_6t

			diff_3
			diff_6) * sampleID / nocum;
run;
ods graphics on;

proc quantreg ci=sparsity/iid algorithm=interior(tolerance=1.e-4) 
                 data=table alpha=0.01;
	by sampleID;
      model diff_3 =  /
                     quantile= 0.05 to 0.95 by 0.15
                     plot=quantplot;
run;
ods graphics off;
ods trace on;
ods graphics on;
proc quantreg ci=sparsity/iid algorithm=interior(tolerance=1.e-4) 
                 data=table alpha=0.01;
      model diff_6 =  /
                     quantile= 0.05 to 0.95 by 0.15
                     plot=quantplot;
	ods output   ParameterEstimates  = Estimates;
run;
ods graphics off;
ods trace off;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
H
Pyrite | Level 9 H
Pyrite | Level 9
Well, it may help if I put the BY statement and the ODS OUTPUT statements in the same procedure 😞

I have resolved the issue!

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

@H wrote:

Hello,

I am using the BY statement in PROC QUANTREG along with ODS OUTPUT in order to generate a dataset with all of the listed quantile estimates for all of the models. The below code does this for just one of the models, instead of all ten which is desired. Further below is the code for a reproducible example.  Any suggestions would be appreciated.


What is your question?

--
Paige Miller
H
Pyrite | Level 9 H
Pyrite | Level 9
My generated dataset of estimates only had output from one model. Though this was because I put the BY statement in the wrong model. It was a simple error on my part. I was trying to run a bunch of datasets through the PROC QUANTREG similarly to a bootstrap approach.
H
Pyrite | Level 9 H
Pyrite | Level 9
Well, it may help if I put the BY statement and the ODS OUTPUT statements in the same procedure 😞

I have resolved the issue!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 656 views
  • 3 likes
  • 2 in conversation