I'm looking to calculate rolling window pairwise correlations, something in SAS that replicates the following python function. Please let me know if you need data and more examples ?
Proc IML doesn't do the trick either :
proc iml;
use work.ret_trans;
read all var{date} into myDates;
read all var _NUM_ into X[colname=NumerNames];
do x=18 to nrow(myDates);
dt=myDates[x];
lagdt = intnx('month',dt,-18,'end');
read all var _NUM_ where(date <= dt & date > lagdt ) into trailing18;
idx = setdif(1:ncol(trailing18), 1);
pc = corr(trailing18);
if x=18 then create work.PairWise from pc ;
else edit work.PairWise ;
append from pc;
end;
quit;
pandas.rolling_corr pandas.rolling_corr(arg1, arg2=None, window=None, min_periods=None, freq=None, center=False, pairwise=None, how=None)
Moving sample correlation.
Parameters: Returns:
arg1 : Series, DataFrame, or ndarray arg2 : Series, DataFrame, or ndarray, optional
window : int
min_periods : int, default None
freq : string or DateOffset object, optional (default None)
center : boolean, default False
how : string, default ‘None’
pairwise : bool, default False
|
y : type depends on inputs
|
If you have SAS/ETS software, you can use PROC EXPAND. See the second example in Vora (2008):
http://www2.sas.com/proceedings/forum2008/093-2008.pdf
A DATA step solution is provided in the same paper.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: