Hello,
I have two data sets (i.e., Temp1 and Temp2). Temp1 has one variable x with 20000 observations, and Temp2 contains four variables y1, y2, z1 and z2 with 60000 observations.
I used the following codes to obtain variable mu, but it took a lot of time to get the result with the large sample sizes. Is there a way that can have SAS run faster? Thanks!
proc sql noprint; select x into :x1 - :x20000 from temp1;quit; data temp3; set temp2; %do i= 1 %to 20000; T&i.= (constant('E')**(y1*(&&x&i.-z1)) - constant('E')**(y2*(&&x&i.-z2)))**2 %end; mu = mean (of T1-T20000)); run;
Then I would get rid of the macro language and the abundant variables. Given that you have no missing values, start with:
data want;
array xval [20000] _temporary_;
if _n_=1 then do k=1 to 20000;
set temp1;
Xval[k]=x;
end;
That makes all 20,000 values of x available. Next, accumulate the numerator:
set temp2;
mu = 0;
do k=1 to 20000;
mu + same formula, using xval[k] not &&x&I;
end;
mu = mu/ 20000;
drop x k;
run;
Thanks for your response, Astounding. I just need mu.
Then I would get rid of the macro language and the abundant variables. Given that you have no missing values, start with:
data want;
array xval [20000] _temporary_;
if _n_=1 then do k=1 to 20000;
set temp1;
Xval[k]=x;
end;
That makes all 20,000 values of x available. Next, accumulate the numerator:
set temp2;
mu = 0;
do k=1 to 20000;
mu + same formula, using xval[k] not &&x&I;
end;
mu = mu/ 20000;
drop x k;
run;
It did get much faster. Thanks so much for your help!!!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.