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!!!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.