BookmarkSubscribeRSS Feed
erynwu
Calcite | Level 5

Hi all,

I found this %CONSORT  macro code to creat the flow diagram from this paper.
Methods of a Fully Automated CONSORT Diagram Macro... - SAS Support Communities

%include 'C:\Users\eryn-wu\Desktop\CONSORT\consort_macro.sas' / nosource;
 proc format;
    value off1f
        1='Ineligible'
        2='Insurance Denied';
    value off2f
        1='Withdrawal'
        2='Progression'
		3='Adverse Event'
        4='Death'
        5='Alternate Therapy'; 
   run;
   data example;
    call streaminit(1);
    array u {1500};
    do j = 1 to dim(u);*Variables;
        u(j)=rand("Uniform");
    end;
    length id 8. arm $25. gender smoke_stat $10. offtrt 8. 
           reg rand treated neo rt surg adj comp $50.;
    do i = 1 to 1500;*Patients;
        id=i;
        call missing(reg,rand,treated,neo,surg,rt,adj,comp);
        arm=catx(' ','Arm',1+round(rand("Uniform"),1));
        sex=ifc(rand("Uniform")>0.50,'Male','Female');
        smoke_chance=rand("Uniform");
        if smoke_chance>0.66 then smoke_stat='Former';
        else if smoke_chance>0.33 then smoke_stat='Current';
        else smoke_stat='Never';
        reg='Registered';
        if u(i)>=0.1 then do;
            rand='Randomized';
            if u(i)>=0.15 then do;
                treated='Started Treatment';
                if u(i)>=0.3 then do;
                    neo='Completed Neoadjuvant~Chemotherapy';
                    if u(i)>=0.35 and arm='Arm 2' then rt='Completed Neoadjuvant RT';
                    if (arm='Arm 1' or ^missing(rt)) and u(i)>=0.4 then do;
                        surg='Completed Surgery';
                        if u(i)>=0.5 then do;
                            adj='Started Adjuvant Therapy';
                            if u(i)>=0.6 then do;
                                comp='Completed All Therapy';
                            end;
                        end;
                    end;
                end;
                if missing(comp) then offtrt2=floor(rand("Uniform")*5+1);
            end;
            else offtrt2=floor(rand("Uniform")*3+1);
        end;
        else offtrt=floor(rand("Uniform")*2+1);
        output;
    end;
    drop u: i j;
    format offtrt off1f. offtrt2 off2f.;
    label arm='Treatment Arm' offtrt='Screen Failure' offtrt2='Off-Treatment'  sex='Sex' smoke_stat='Smoking Status';
run;

%CONSORT(data=example2,id=id,
node=reg rand treated neo,
split=|arm,
offreason=offtrt|offtrt2,
offreason_label=Screen Failure|Off-Treatment);

but when I used the code, the result was not show same with paper.
Mine figure showed the lable of total but the paper did't showed.
Beside that, the offtrt2 label also can't show properly.
I had try by using SAS 9.4 and also Studio.
Does anyone else know any tips or tricks to get it to work?

2 REPLIES 2
erynwu
Calcite | Level 5

the diagram I got.

consort.png

Mipaskew
Calcite | Level 5

I ran into the same issue. The unformatted data in the columns used to specify the categories for the offreason and or freq parmaters are numeric. As a result the missing values are represented by a period. When these values are processed into character strings, the period carries over instead of a mapping to a blank cell. The subsequent steps in the macro treat cells with a "." the same as a if they held a legitimate value (e.g. "Insurance Denied").

Setting the system option to display a blank cell instead of a "." should work:

options missing="";

If not, you'll likely have to update the macro itself to remove periods from the offrsn and freq columns in the temporary tables. The compress function would probably work for this solution. The examples below would keep only the alphabetic characters of a string:

compress(offrsn,,'ka')
compress(freq,,'ka')

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
  • 464 views
  • 0 likes
  • 2 in conversation