Question

proc sql noprint;  
    select count(distinct USUBJID) into : N1 - : N4 from DM where upcase(ARM) ^= "SCREEN FAILURE"`   
    group by ARMN;  
quit; 

%macro TOTAL(name=,num=);   
    %do i=1 %to #`    
    %if ARMN=&i %then TOTAL= put(COUNT,3.)||" (" ||right(put(COUNT*100/&&name&num,5.1))||"%) ";  
%end;    
%mend TOTAL;    

data TOTAL;    
    set DS;     
    %TOTAL(name=T,num=4);   
   /*if ARMN=1 then TOTAL= put(COUNT,3.)||" (" ||right(put(COUNT*100/&N1,5.1))||"%) ";*/    
run;

The above code is to assign number of subjects in treatment groups to macro variables and using the same to calculate the percentage as shown in the above code. The macro block written is not getting resolved in the datastep TOTAL and is not throwing a warning or an error.

Was it helpful?

Solution

I think your highest level problem is what @DmitryShopin mentions in his comment. However, my answer may be what is stopping the macro from resolving.

Your %If %Then statement within the %Total macro needs another semi-colon at the end. One semi-colon for the variable assignment statement and one semi-colon for the %If %Then statement. If you are generating more than one variable assignment statement, each one needs an ending semi-colon.

Not sure if this is the only problem without having sample data to test it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top