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);
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.