Advertisement
elena1234

correlation heatmap in SAS

Apr 8th, 2023 (edited)
1,343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 1.30 KB | Source Code | 0 0
  1. ods excel file='/home/u63376027/Export/Correlation_Heatmap.xlsx' style=seaside;
  2. proc template;
  3. delete Base.Corr.StackedMatrix / store=sasuser.templat;
  4. edit Base.Corr.StackedMatrix;
  5. column (RowName RowLabel) (Matrix);
  6. header 'Pearson Correlation Coefficients';
  7. edit matrix;
  8. format=5.2;
  9. cellstyle
  10. _val_ <= -1 as {backgroundcolor=CXFF0000},
  11. _val_ <= -0.75 as {backgroundcolor=CXFF007D},
  12. _val_ <= -0.5 as {backgroundcolor=CXFF00FA},
  13. _val_ <= -0.25 as {backgroundcolor=CX7D82FF},
  14. _val_ <= 0 as {backgroundcolor=CX00FFFF},
  15. _val_ <= 0.25 as {backgroundcolor=CX7D82FF},
  16. _val_ <= 0.5 as {backgroundcolor=CXFF00FA},
  17. _val_ <= 0.75 as {backgroundcolor=CXFF007D},
  18. _val_ <= 1 as {backgroundcolor=CXFF0000};
  19. 12
  20. end;
  21. end;
  22. quit;
  23. ods pdf style=sapphire;
  24. options nolabel;
  25. proc corr data=STPSAMP.STPEURO(drop=id:) noprob; /* data set */
  26. ods select PearsonCorr;
  27. run;
  28.  
  29. %paint(values=-1 to 1 by 0.25, macro=setstyle, colors=red magenta cyan magenta red)
  30. proc template;
  31. delete Base.Corr.StackedMatrix / store=sasuser.templat;
  32. edit Base.Corr.StackedMatrix;
  33. column (RowName RowLabel) (Matrix);
  34. header 'Pearson Correlation Coefficients';
  35. edit matrix;
  36. format=5.2;
  37. %setstyle(backgroundcolor)
  38. end;
  39. end;
  40. quit;
  41. proc corr data=STPSAMP.STPEURO(drop=id:) noprob; /* data set */
  42. ods select PearsonCorr;
  43. run;
  44. ods excel close;
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement