Hi,
I want to draw lasagna plot which shows the changeable of categories over time.
I wrote code as follows:
proc template;
define statgraph heatmapparm;
begingraph;
layout overlay;
heatmapparm x=x1 y=y1 colorresponse=z1 /
name="heatmapparm" xbinaxis=false ybinaxis=false colormodel=(green yellow orange) XGAP=2;
continuouslegend "heatmapparm" / location=outside valign=bottom;
endlayout;
endgraph;
end;
run;
proc sgrender data=dataset template=heatmapparm;
run;
Then I got a graph like the following:
However, I want to sort every column which would be easier to see the changeable. Is there any solution for this?
Thank you in advance.
In case it is helpful, I discuss how to sort rows of the lasagna plot in a blog post and provide an example. I used PROC IML, but I think you can do something similar by using the CALL SORT function in the DATA step to sort each row of the data independently. You'll have to set up an array that references the variables/columns.
You would need to sort your data by x1 z1_0 z1_1 ... z1_20, where z1_n is the value of z1 when x1=n.
In case it is helpful, I discuss how to sort rows of the lasagna plot in a blog post and provide an example. I used PROC IML, but I think you can do something similar by using the CALL SORT function in the DATA step to sort each row of the data independently. You'll have to set up an array that references the variables/columns.
Thank you very much. I got it. Attached with my code in case someone has the same question.
ods graphics / width=500px height=650px;
proc iml;
varName = "bmi_lasa1":"bmi_lasa5";
use bmi_lasag ;
read all var varName into X[rowname=l_pnr1];
close bmi_lasag;
palette = "CXFFFFFF" || palette("YLORRD", 4); /* palette from colorbrewer.org */
call sort (x,{1 2 3 4 5 },{1 2 3 4 5 }); /*this part is the answer*/
Sort2 = X; /* copy original data */
call heatmapcont(Sort2) xvalues=1:5
displayoutlines=0 colorramp=palette;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.