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.

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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