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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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;

View solution in original post

4 REPLIES 4
Astounding
PROC Star
When all is said and done, do you need T1-T20000, or do you just need mu?
Jenc
Calcite | Level 5

Thanks for your response, I just need mu. 

Astounding
PROC Star

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;

Jenc
Calcite | Level 5

It did get much faster. Thanks so much for your help!!!

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 879 views
  • 0 likes
  • 2 in conversation