BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jie111
Quartz | Level 8

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.

4$EZU}_DJ$O%QJWBK}4_W~1.png

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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.

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

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.  

PG
Jie111
Quartz | Level 8
Thank you for the reply.
Actually I did this:
PROC SORT DATA=RUSH.rush_long;
by fu_year dcfdx_g;
run;


But it only impacts the first column (z1_0). I do not know how to sort other columns.
Rick_SAS
SAS Super FREQ

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.

Jie111
Quartz | Level 8

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;

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1254 views
  • 0 likes
  • 3 in conversation