Hi. I'm SupermanJP.
I updated SAS plotter, modern data visualization package for SAS base.
https://github.com/Superman-jp/SAS_Plotter
document
https://superman-jp.github.io/SAS_Plotter/
new features
official mail address: sasplotter@picolabs.jp
official web site (Japanese) https://picolabs.jp
Please feel free to contact me if you have any bug reports, feedback, or requests.
Hello SupermanJP,
Nice work!
How to get your input data set named "raw" to your code?
Thanks,
I apologize for the lack of clarity. i will revise the document.
"raw" dataset means input data you want to make sankey.
if you want to sankey using this macro, prepare the input data with structure.
Sorry I mean to find the SAS data set named "raw" in your SAS code to replicate the graph here.
Thanks,
Examples are a *lot* more useful, when they include the sample data!
Raw data should look like in this example this:
data raw;
subjID+1;
input day0 day30 day60 day120;
cards;
0 2 3 4
0 2 3 4
0 2 3 4
2 1 2 4
2 1 2 4
2 1 2 4
2 1 2 4
2 1 2 4
2 1 4 3
4 3 2 1
4 3 2 1
4 3 2 1
4 3 2 1
;
run;
Basically each row (each subjid) indicates which drug was taken by a given patient during given time, e.g.
If patient 1 took drug 0 on the day 0, then drug 2 on the day 30, drug 3 on the day 60 and drug4 on day 120, the observation will be:
data raw;
input subjID day0 day30 day60 day120;
cards;
1 0 2 3 4
;
run;
Result of the following snippet:
proc format;
value domainf
1="day0"
2="day30"
3="day60"
4="day120";
value nodef
0="Drug A"
1="Drug B"
2="Drug C"
3="Drug D"
4="Drug E"
;
run;
data raw;
subjID+1;
input day0 day30 day60 day120;
format day0 day30 day60 day120 nodef.;
cards;
0 2 3 4
0 2 3 4
0 2 3 4
2 1 2 4
2 1 2 4
2 1 2 4
2 1 2 4
2 1 2 4
2 1 4 3
4 3 2 1
4 3 2 1
4 3 2 1
4 3 2 1
;
run;
ods graphics / height=15cm width=20cm imagefmt=svg imagename="sankey_basic" noborder;
ods listing gpath="R:\";
ods html;
%sankey(
data=raw,
domain=day0 day30 day60 day120,
domainfmt=domainf
);
looks like this:
Bart
One more example:
data raw;
call streaminit(123);
do subjID = 1 to 1000;
array A day0 day30 day60 day120;
format day0 day30 day60 day120 nodef.;
do over A;
A = rand('integer',0,4);
end;
output;
end;
run;
which, with the same snippet, produces this:
Hello SupermanJP,
1)How to add a title and footnote into the Sankey charts?
2)Howe to adjust the Sankey charts wider?
Thanks,
1)I tried to add title and footnote statements in the "proc template" of your Sankey macro code but I couldn't make it work.
2)I expect to adjust the width of Sankey chart similar to ods statement below used for "proc sgplot".
"ods graphics /imagefmt=png imagename="&name"
width=1500px height=800px;"
Thanks ,
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.