BookmarkSubscribeRSS Feed
SupermanJP
Obsidian | Level 7

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

 

  •  new plots " sankey diagram" was available!

ezgif-2-7d9e0864f0.pngsankey_basic+(1).png
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.

27 REPLIES 27
t75wez1
Pyrite | Level 9

Hello SupermanJP,

Nice work!

How to get your input data set named "raw" to your code?

Thanks,  

SupermanJP
Obsidian | Level 7

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.

SupermanJP_0-1718067631371.png

 

 

t75wez1
Pyrite | Level 9

Sorry I mean to find the SAS data set named "raw" in your SAS code to replicate the graph here.

Thanks,

SupermanJP
Obsidian | Level 7
the "raw" dataset is not included in SAS plotter package. sorry. I will add the raw dataset at next version.
GraphGuy
Meteorite | Level 14

Examples are a *lot* more useful, when they include the sample data!

SupermanJP
Obsidian | Level 7
if you have additional idea, Please feel free to contact me.

by the way, you are so handsome.
yabwon
Onyx | Level 15

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:

yabwon_0-1718780403630.png

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

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:

yabwon_0-1718781741110.png

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SupermanJP
Obsidian | Level 7
Thanks. Very informative.
t75wez1
Pyrite | Level 9

Hello SupermanJP,

1)How to add a title and footnote into the Sankey charts?

2)Howe to adjust the Sankey charts wider? 

Thanks,  

SupermanJP
Obsidian | Level 7
1) you can use title statement or footnote statement.
but you want to add title or footnote into output image?
if you mean , this macro is not contained setting the title and footnote.

2) you mean you want to adjust the width of output image generated by sankey macro?
could you tell me the details?
t75wez1
Pyrite | Level 9

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 , 

SupermanJP
Obsidian | Level 7
1) title string can be add by entrytitle statement in graph template.

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/n0zp1mg0ard2dan17sohm8jb773n.htm

but I will add the title and footnote parameter to the sankey macro.

2 )
submit below code before executing the sankey macro.
"ods graphics /imagefmt=png imagename="&name"
width=1500px height=800px;"

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 27 replies
  • 2496 views
  • 15 likes
  • 4 in conversation