を解決しません。マクロ変数は、私はマクロ「quantplot」を実行すると、私は写真のような問題に遭遇SAS
実際に起こっているように見えるのは、この形式の式recode_ &変数、out_ &変数などが正しい値を返すように見えないということです。単にrecode_と読み、マクロ変数を無視しているだけです。
data test (drop=i);
do i=1 to 1000;
a=round(uniform(1)*4,.01);
b=round(uniform(1)*10,.01);
c=round(uniform(1)*7.5,.01);
u = rand("Uniform");
y=floor((2)*u);
output;
end;
stop;
run;
%macro percentiles(indep_var=,num_groups=);
%let recodes=recode_%sysfunc(tranwrd(&indep_var,%str(),%str(recode_)));
proc rank data=test out=test groups=7;
var &indep_var;
ranks &recodes;
run;
%mend;
%percentiles(indep_var=a b c);
そしてまた、現在動作していないマクロのコード:
私は、サンプルデータのための次のコードを提供してきました。助けてください!
/*Plots to determine functional form for quantitative variables*/
%macro quantplot(indep_var=,dep_var=);
/* Count the number of words in the input */
%let count=%sysfunc(countw(&indep_var));
/* Loop through the total number of values */
%do i = 1 %to &count;
%let variables=%qscan(&indep_var,&i,%str());
%put(&variables);
proc means data=test;
%put(&variables);
class recode_&variables;
var &dep_var;
output out = out_&variables mean = pby_&variables;
run;
data p_&variables;
set out_&variables; if _type_=1;
lnp = log(pby_&variables/(1-pby_&variables));
run;
ods graphics on;
proc gplot data = p_&variables;
symbol value = star i=join;
plot lnp*recode_&variables;
plot pby_&variables*recode_&variables;
run;
ods graphics off;
%end;
%mend;
%quantplot(indep_var=a b c,dep_var=y);
質問には関係ありませんが、gplotではなくsgplotを使用することをお勧めします。あなたはより良いグラフィックス、より多くのコントロールを取得し、私の意見で使用するのが簡単です。 – Reeza
https://gist.github.com/statgeek/7cffd06ebc3bc9c78b4f6a5b4538b053 – Reeza
procランクを自動化するための私のバージョンのマクロ。 – Reeza