I've got code as below and I would like to make an if statements [in new column, let's call it flag] on data test, where i could use macro defined quintiles [from proc univariate step 1 in macro]. In the end i would like to see if each record falls in defined quantiles or if not, flag should be something else.
I stopped on the step where I'm defining macro variables. How can I order SAS to define Q1 as pct10 which is output from proc univariate?
data test;
do x=1 to 100;
output;
end;
x=.;
output; output;
run;
example %quint(test,x,10 20 30 70)
%macro quint(input=,var=, pcts=);
/* calculate the cutpoints for the quintiles */
proc univariate data=&input;
var &var;
output out=quintile pctlpts=&pcts pctlpre=pct;
run;
/* write the quintiles to macro variables */
data _null_;
set quintile;
%do i=1 %to %sysfunc(countw(&pcts));
call symput(cats("Q",&i),cats("pct",%scan(&pcts,&i,' ')));
%put "&&Q&i";
%end;
run;
there should be data test with new column flag based on macrovariables created from proc univariate Q1 to Qx
%mend quint;