I was trying to minic the macro code (link as below) to create a table, which is supposed to display median, qrange as well as p value from wilcoxon test for a continous variable called 'sum_PT_mins_1yr' by a categorical variable called 'race'.
http://www.lexjansen.com/nesug/nesug08/ff/ff06.pdf
My code is below:
%macro continuous(cpred, i);
proc univariate data=temp3.PTestimate (where=(race in (1, 2) and &cpred>0))) noprint;
class race;
var &cpred;
output out=Quantilestatistics&i median=median qrange=qrange;
run;
proc npar1way data=temp3.PTestimate (where=(race in (1, 2) and &cpred>0))) wilcoxon;
class race;
var &cpred;
output out=wilcoxon&i(keep=P2_WIL) wilcoxon ;
run;
data pvalue&i;
set wilcoxon&i;
if 0.0001<=P2_WIL< = 0.05 then p_value = (round(P2_WIL,0.0001)||'*');
else if P2_WIL<0.0001 then p_value = ('<0.0001'||'*');
else p_value = round(P2_WIL,0.0001);
keep p_value;
run;
data descript&i;
merge Quantilestatistics&i pvalue&i;
cmedian = put(median,8.2);
cqrange = put(qrange,8.2);
median_qrange = (trim(left(cmedian))) || ' (' || trim(left(cqrange)) || ')';
drop median qrange;
run;
proc transpose data=descript&i out=tdescript&i;
var median_qrange;
copy p_value;
run;
%mend continuous;
%macro contiunous (sum_PT_mins_1yr, 1);
However, I got an error message from the log:
ERROR: Invalid macro parameter name 1. It should be a valid SAS identifier no longer than 32
characters.
ERROR: A dummy macro will be compiled.
I have no clue how to fix this problem. Probably I have more errors than that in this code... Your suggestions would be highly appreicated. Thank you.
One mistake is that your macro call doesn't match macro name - spelling error. You also use the word macro again, which isn't correct, it's just the macro name.
%macro contiunous (sum_PT_mins_1yr, 1);
It should be:
%continuous(sum_PT_mins_1yr, 1);
One mistake is that your macro call doesn't match macro name - spelling error. You also use the word macro again, which isn't correct, it's just the macro name.
%macro contiunous (sum_PT_mins_1yr, 1);
It should be:
%continuous(sum_PT_mins_1yr, 1);
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.