Solved
Contributor
Posts: 64

# macro error on generating customized analytical reports from sas procedure output

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.

Accepted Solutions
Solution
‎07-26-2016 03:58 PM
Super User
Posts: 23,776

## Re: macro error on generating customized analytical reports from sas procedure output

Posted in reply to Crystal_F

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);``

All Replies
Solution
‎07-26-2016 03:58 PM
Super User
Posts: 23,776

## Re: macro error on generating customized analytical reports from sas procedure output

Posted in reply to Crystal_F

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);``

Contributor
Posts: 64

## Re: macro error on generating customized analytical reports from sas procedure output

What a stupid mistake that I made! My bad. Many thanks! I'll keep on checking whether other pieces of my code work here.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
• 2 replies
• 1323 views
• 1 like
• 2 in conversation