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

Hello 

 

I am using (proc lifereg) in my SAS IML, So I used submit and endsubmit  to get out of IML and then I used (Use-Read-Close) to save my results from the previous step and save them on a vector for later use.

The problem is that I can't print my final answer.  I am not sure what else do I need to do.  Any help is highly highly appreciated. Thank you.

 

proc iml;
	k=10;
	seed=0;
	scheme=1;
	n=30;
	m=20;
	r=J(m, 1, 0);
	r[m]=10;
	sigma1=1;
	sigma2=1;
	pi=22/7;
	ru=0.2;
	* this is the correlation;
	mu1=0;
	mu2=0;
	B0=1;
	B1=0.2;
	lambda=.5;
	Y=J(m, 1, 0);
	XX=J(m, 1, 0);
	** Simulation of progressive censoring ****;
	Ww=J(m, 1, 0);
	X=J(m, 1, 0);
	UU1=J(m, 1, 0);
	U2=J(m, 1, 0);
	T1=J(n, 1, 0);
	V=J(n, 1, 0);
	Y1=J(m, 1, 0);
	Z1=J(n, 1, 0);
	Z2=J(n, 1, 0);
	Ee=J(m, 1, 0);
	Vv=J(m, 1, 0);
	ll=J(m, 1, 0);
	EST1=J(n, 1, 0);
	EST3=J(n, 1, 0);

	Do N1=1 to K;
		** Creation of the progressive data from Uniform;
		************************************************;

		do i=1 to m;
			Ww[i]=Uniform(seed);
			ll[i]=i;
			sum=0;

			do j=m-i+1 to m;
				sum=(R[j]+sum);
			end;
			Ee[i]=1/(i+sum);
			Vv[i]=Ww[i]**Ee[i];
		end;

		do i=1 to m;
			prod=1;
			endloop=m-i+1;

			do k1=m to endloop by -1;
				prod=Vv[k1]*prod;
			end;
			UU1[i]=1-(prod);
			** the U's are the required progressively type II
right censored sample from U(0,1);
		end;
		U_obs=UU1||J(m, 1, 1);
		** progressive censored data of size m from U(0,1) with idex=1 to indicate the event occurs;
		** I need the data to have a size n, so I need to generate more data from Uniform(0,1) with size of n-m;
		UU0=J(n-m, 1, 0);

		do j=1 to n-m;
			UU0[j]=Uniform(seed);
		end;
		U_Cen=UU0||J(n-m, 1, 0);
		* These are the censored data with idex 0;
		U=J(n, 2, 0);
		U=U_obs//U_cen;
		U_1=U[, 1];
		* This is the first column of the matrix U which represents the data from Uniform both(observed + censored);
		U_2=U[, 2];
		* This is the index (1:failure OR 0:Censored);
		Z1=quantile('Normal', U_1);
		* this is how we generate the covariate vector which is associated with Beta1;

		/*do j=1 to n;
		
		V[j]=Uniform(seed);
		
		end;
		
		 *Z2=quantile('Normal',V);
		
		y1=(ru#Z1+sqrt(1-ru**2)#Z2)#sigma2+mu2; **/
		C=B0+B1#Z1;
		T1=exp(C)#(-log(U_1))##lambda;

		/*Weibull**;*/
		/* (1) To use the values of my r.v. in proc lifereg, we need to write them to a SAS data set using CREATE and APPEND
		statements. These statements create data set AFT;*/
		create AFT var {"U_obs", "U_Cen", "U" , "U_1" , "U_2", "T1", "Z1"};
		append;
		close AFT;
		* (2) Next, the lifereg procedure is called from within IML by using SUBMIT and ENDSUBMIT statements. ;
		submit;

	proc lifereg data=AFT outest=AFT_out covout;
		model T1*U_2(0)=Z1 / dist=WEIBULL;
	run;

	data new_AFT;
		set AFT_out;
		keep Z1;
	run;

	proc transpose data=new_AFT out=idnumber name=Test prefix=sn;
	run;

	endsubmit;
	* (3) To read the results back to SAS/IML we write "use", "read", and "close";
	Use idnumber;
	read all var {Sn1 Sn2 Sn3 Sn4};
	Close idnumber;
	Est1[N1]=Sn1;
	end;
	*end of simulation loop (NN);
	Est1_Hat=Est1[:];
	print Est1_Hat;
	Quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

When I run your code, it prints the Est1_Hat value. I suspect at some point you were experimenting with ODS SELECT or ODS EXCLUDE or even ODS close;

 

Try submitting 

ODS SELECT ALL;

and rerunning the program. If there is still no output, make sure a destination is open, such as

ODS HTML;

 

If you are still having problems, save the program and restart SAS. Unless there are statements that you did not post, the program should print the output.

 

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

When I run your code, it prints the Est1_Hat value. I suspect at some point you were experimenting with ODS SELECT or ODS EXCLUDE or even ODS close;

 

Try submitting 

ODS SELECT ALL;

and rerunning the program. If there is still no output, make sure a destination is open, such as

ODS HTML;

 

If you are still having problems, save the program and restart SAS. Unless there are statements that you did not post, the program should print the output.

 

Salah
Quartz | Level 8

Thank you Rick

 

It works thank you so much.

 

Salah

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 726 views
  • 0 likes
  • 2 in conversation