I want to create a Sankey diagram in Stata. I have installed the Sankey package and have been inspired by GitHub: GitHub - asjadnaqvi/stata-sankey: A Stata package for Sankey diagrams. I have a database with 497 patients, each having a unique ID from 1-497 to differentiate them. Each patient has a characteristic variable, "x," which is a count that can be counted at different tissue sections for each patient. When I count at tissue section 1 for all patients, I categorize the count (into 4 outcomes) in variable A. Similarly, for tissue section 2, I categorize the counts for each patient in variable B, and the same for tissue section 3 in variable C. Variables A, B, and C thus contain the same 4 categories, but counted at different tissue sections. With a Sankey diagram, I want to show how this categorization changes across the different sections while being able to track each patient. Therefore, I would like to create a Sankey diagram in Stata that displays the movements between variable A, variable B, and variable C. I have managed to achieve this using these commands:
sankey id, from(variable A) to(variable B)
sankey id, from(variable B) to(variable C)
The values that Stata assigns on the diagram don't seem to correspond to anything specific. I am not sure if it adds the ID numbers or something else. However, I can adjust this manually in PowerPoint afterwards, so it is the least of my concerns. I can combine the two diagrams manually to see movements from A to B and from B to C. But I want to visualize variable A all the way from A through B to C. Is there any way to do this based on my textual variable? I have tried a few different approaches, but I get errors.
I have attached the current plots corresponding to the stata code previous
Best regards, Maria
sankey id, from(variable A) to(variable B)
sankey id, from(variable B) to(variable C)
The values that Stata assigns on the diagram don't seem to correspond to anything specific. I am not sure if it adds the ID numbers or something else. However, I can adjust this manually in PowerPoint afterwards, so it is the least of my concerns. I can combine the two diagrams manually to see movements from A to B and from B to C. But I want to visualize variable A all the way from A through B to C. Is there any way to do this based on my textual variable? I have tried a few different approaches, but I get errors.
I have attached the current plots corresponding to the stata code previous
Best regards, Maria
Comment