Columns Created in Layout Lattice do not match the sort order of Bar Chart

232 Views Asked by At

I am using proc template to create a swimmers lane plot. I'm using layout lattice to create 3 columns, the first 2 are row identifiers and the third is the barchart. However, the first 2 columns do not match the sort order on the barchart. Below is the code.

PROC TEMPLATE;
    Define statgraph swimmer2;
        Begingraph / designwidth=900px designheight=900px;
        
        layout lattice/columns=3 columngutter=2
            columnweights=(.25 .05 .65);
            
        column2headers;
            entry halign=center "Cohort"/textattrs=(size=7.5pt weight=bold);
            entry halign=center "Subject ID"/textattrs=(size=7.5pt weight=bold);
        endcolumn2headers;
        
        /*Cohort*/
        layout overlay/walldisplay=none border=false
                       yaxisopts=(display=none reverse=true type=discrete)
                       xaxisopts=(display=none offsetmin=0.5 offsetmax=1);
        scatterplot y=subjid x=col1/ markercharacter=col1 markerattrs=(size=0) ;
        endlayout;
        
        /*Subject*/
        layout overlay/walldisplay=none border=false
                       yaxisopts=(display=none reverse=true type=discrete)
                       xaxisopts=(display=none offsetmin=0.19 offsetmax=.85);
            scatterplot y=subjid x=subjid/markercharacter=subjid markerattrs=(size=0) ;
        endlayout;
        
        Layout Overlay/
        xaxisopts=(label="Weeks" labelattrs=(weight=bold size=10pt)
            linearopts=(viewmin=0 viewmax=40
            TICKVALUESEQUENCE=(start=0 end=72 increment=5))
            griddisplay=on
            offsetmin=0 offsetmax=0
            tickvalueattrs=(weight=bold size=8pt)) 
        yaxisopts=(label="Subjects" labelattrs=(weight=bold
            size=10pt)
            tickvalueattrs=(weight=bold size=6pt)
            type=discrete
            offsetmin=0.03 offsetmax=0.03
            display=all);

        HIGHLOWPLOT y=subjid low=low high=week/
            group=TRT01A index=trt01an
            TYPE=LINE LINEATTRS=(THICKNESS=8PT)
            HIGHCAP=CAP
            HIGHLABEL=week LABELATTRS=(COLOR=CX000000)
            name="trt01a" grouporder=descending ;
    
        SCATTERPLOT x=pd_ady y=subjid/MARKERATTRS=(SIZE=5pt color=cx2a8307
        SYMBOL=trianglefilled) name="PD" LEGENDLABEL="PD";

        SCATTERPLOT x=ne_ady y=subjid/MARKERATTRS=(SIZE=5pt color=cxff9900 
        SYMBOL=circlefilled) name="NE" LEGENDLABEL="NE";
        
        SCATTERPLOT x=sd_ady y=subjid/MARKERATTRS=(SIZE=5pt color=cxff0000 
        SYMBOL=squarefilled) name="SD" LEGENDLABEL="SD";
        
        SCATTERPLOT x=tf_ady y=subjid/MARKERATTRS=(SIZE=5pt color=cx13478c 
        SYMBOL=diamondfilled) name="TF" LEGENDLABEL="TF";       

        DISCRETELEGEND "PD" "NE" "TF" "SD"/ location=outside valign=center
        halign=right titleattrs=(weight=bold size=8pt) 
        valueattrs=(weight=bold size=8pt) across=1 ;
    endlayout;
    endlayout;
    endgraph;
    end;
run;

Attached is the output.

Thank you in advance. enter image description here

1

There are 1 best solutions below

0
On

You have this on your first two plot statements:

yaxisopts=(... reverse=true)

But you don't have it on your third one! Add it to the third one, or remove it from the first two, and their axes will match.