So my code should be
filename progfile temp;
data _null_;
set combination;
file progfile;
line = cats('%corr(',variable,',',variable_paired,')');
put line;
run;
%include progfile;
filename progfile clear;
Misunderstandings like this are a main reason why we always ask to provide example data in readily usable form, which means as data steps with datalines.
We can then simply copy the code to our environment and submit it, and there's no questions at all about dataset names, raw content, variable types and other attributes.
So your first dataset should be posted as
data have;
input Date :date9. Variable1 Variable2 Variable3;
format date date9.;
datalines;
31JAN2000 1.3 5.0 9.1
29FEB2000 5.1 6.7 9.8
;
Personally, I prefer to use the YYMMDD10. format/informat for dates, as this is the international standard (ISO 8601)
Write the code to a file, and include it:
filename progfile temp;
data _null_;
set have;
file progfile;
line = cats('%corr(',var1,',',var2,')');
put line;
run;
%include progfile;
filename progfile clear;
So my code should be
filename progfile temp;
data _null_;
set combination;
file progfile;
line = cats('%corr(',variable,',',variable_paired,')');
put line;
run;
%include progfile;
filename progfile clear;
Misunderstandings like this are a main reason why we always ask to provide example data in readily usable form, which means as data steps with datalines.
We can then simply copy the code to our environment and submit it, and there's no questions at all about dataset names, raw content, variable types and other attributes.
So your first dataset should be posted as
data have;
input Date :date9. Variable1 Variable2 Variable3;
format date date9.;
datalines;
31JAN2000 1.3 5.0 9.1
29FEB2000 5.1 6.7 9.8
;
Personally, I prefer to use the YYMMDD10. format/informat for dates, as this is the international standard (ISO 8601)
PS SYSFUNC does not play any role here.
%SYSFUNC is a macro function which allows to use (most) data step functions while the macro preprocessor executes macro code.
What my code does (in detail):
You can directly read the combinations data set and dynamically make the macro call with call execute.
UNTESTED
data _null_;
set combinations;
cmd = cats('%corr(', variable, ',', variable_paired, ');');
*put cmd=; * confirm syntax;
call execute(cmd);
run;
Why do you need such complications?
proc corr data=have;
var variable1-variable10 ;
run;
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.