Hello Paige, Your code is great. I'm only having an issue to calculate the function PRODDUR which is the multiplication between 2 variables (var1 and Var2). Such variable is important to find the correlation. I tried to use it inside the macro as following: %macro movingcorr(variables=);
%let numvar = %sysfunc(countw(&variables));
%do i=1 %to &numvar;
%let var1=%scan(&variables,&i,%str( ));
%do j=1 %to &numvar;
%if &j gt &i %then %do;
%let var2=%scan(&variables,&j,%str( ));
%let proddur= &var1*&var2;
proc expand data=WORK.gics out=out_&var1._&var2;
convert &var1 = v1sum /method=none transformout=(movsum 21);
convert &var2 = v2sum /method=none transformout=(movsum 21);
convert &var1 = v1ss /method=none transformout=(movcss 21);
convert &var2 = v2ss /method=none transformout=(movcss 21);
convert &proddur = proddursum /method=none transformout=(movsum 21);
run;
data corr_&var1._&var2;
set out_&var1._&var2;
corr_&var1._&var2 = (proddursum - (v1sum*v2sum)/21 / (sqrt(v1ss)*sqrt(v2ss));
%end;
%end;
%end;
%mend;
%movingcorr(variables = v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11) Since I need the proddursum to calculate the correlation, as you can see, I need to find the proddur. However, the following erros appears for me: 149 v1*v2
_
22
6 The SAS System 16:10 Thursday, May 16, 2019
200
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, /, :, =, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.
ERROR 200-322: The symbol is not recognized and will be ignored.
79: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 79-322: Expecting a ). The same error appears for all correlations (v1*v3, v1*v4...). What would you recommend? Thanks Pedro
... View more