elliott828 发表于 2010-1-21 18:09 
2# bobguy 第四条我不太理解。
你的意思是不是让我弄出一个表格出来,表格里有所有的变量名。然后把这个表设定成&var?
比如说我在设定参数的时候写:%macro corr(lib,table,var)
关于变量的参数只有var一个,如果我要从中选取两个变量,那我应该怎么调用macro呢?
还有就是有时候字符型数据也是可以跟数值型数据产生关系的啊(比如说性别跟头发长度,性别跟身高),不能一概都删掉吧
谢谢了
"还有就是有时候字符型数据也是可以跟数值型数据产生关系的啊(比如说性别跟头发长度,性别跟身高),不能一概都删掉吧"
That is different concept here. The distribution of height may be gender dependent. You may compare the means and deviation by gender, but not correlations. You may measure the correlation between weight and height in male or in female separately.
*************************************************;
Here is an example to illustrate my comments.
%macro corr(dsn=, drop=, where=, odsn=corr);
%if %length(&drop)=0 %then %let dp=%str( );
%else %let dp=(drop=&drop);
%if %length(&where)=0 %then %let whereit=%str( );
%else %let whereit=&where %str(;);
proc corr data=&dsn &dp outp=&odsn(where=(_type_='CORR')) noprint;
&whereit
run;
%mend;
%corr(dsn=sashelp.class, drop=, where=, odsn=corr2);
proc print; run;
%corr(dsn=sashelp.class, drop=, where=where ranuni(-1) <0.3, odsn=corr2);
proc print; run;