BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Crystal_F
Quartz | Level 8

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

 

View solution in original post

2 REPLIES 2
Reeza
Super User

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

 

Crystal_F
Quartz | Level 8
What a stupid mistake that I made! My bad. Many thanks! I'll keep on checking whether other pieces of my code work here.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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