-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6a09ae
commit 592f0ab
Showing
7 changed files
with
52 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
*! sankey v1.7 (06 Nov 2023) | ||
*! sankey v1.71 (15 Jan 2024) | ||
*! Asjad Naqvi ([email protected]) | ||
|
||
*v1.7 (06 Nov 2023): fix valcond() dropping labels in bars, added percent (still in beta), add ctitlepos() option. minor cleanups | ||
*v1.71 (15 Jan 2024): fixed a bug where value labels of to() and from() were overwriting each other. | ||
*v1.7 (06 Nov 2023): fix valcond() dropping labels in bars, added percent (still in beta), added ctpos() option. minor cleanups | ||
*v1.61 (22 Jul 2023): Adding saving() option. minor fixes | ||
*v1.6 (11 Jun 2023): Major rewrite of the core routines. Labels added. twp sorts added. Program is faster. | ||
*v1.52 (29 May 2023): Add option where wwn flows are considered stock | ||
|
@@ -43,7 +44,7 @@ version 15 | |
// check dependencies | ||
cap findfile colorpalette.ado | ||
if _rc != 0 { | ||
display as error "The palettes package is missing. Install the {stata ssc install palettes, replace:palettes} and {stata ssc install colrspace, replace:colrspace} packages." | ||
display as error "The {bf:palettes} package is missing. Install the {stata ssc install palettes, replace:palettes} and {stata ssc install colrspace, replace:colrspace} packages." | ||
exit | ||
} | ||
|
||
|
@@ -122,10 +123,31 @@ preserve | |
|
||
keep `varlist' `from' `to' `by' clrlvl | ||
|
||
// convert value labels to strings | ||
cap confirm numeric var `from' | ||
if _rc==0 { | ||
if "`: value label `from''" != "" { | ||
decode `from', gen(temp1) | ||
drop `from' | ||
ren temp1 `from' | ||
} | ||
} | ||
|
||
cap confirm numeric var `to' | ||
if _rc==0 { | ||
if "`: value label `to''" != "" { | ||
decode `to', gen(temp2) | ||
drop `to' | ||
ren temp2 `to' | ||
} | ||
} | ||
|
||
|
||
collapse (sum) `varlist' (mean) clrlvl , by(`from' `to' `by') | ||
|
||
gen markme = . | ||
|
||
|
||
if "`stock'" != "" { | ||
replace markme = `from'== `to' | ||
} | ||
|
@@ -165,6 +187,8 @@ preserve | |
|
||
reshape long var val, i(id layer xcut) j(marker) | ||
|
||
|
||
|
||
// variable type check | ||
|
||
if substr("`: type var'",1,3) != "str" { | ||
|
@@ -181,6 +205,7 @@ preserve | |
} | ||
|
||
|
||
|
||
gen layer2 = layer | ||
replace layer2 = layer2 + 1 if marker==2 | ||
|
||
|
@@ -258,7 +283,8 @@ preserve | |
gen double y2 = heightsum | ||
|
||
|
||
|
||
|
||
|
||
*** add gap | ||
|
||
tempvar mygap | ||
|
@@ -306,6 +332,8 @@ preserve | |
|
||
} | ||
|
||
|
||
|
||
gsort layer2 marker var markme `ssort2' // this determines the second sort | ||
|
||
by layer2 marker var: gen double stack_end = sum(val) if markme!=1 | ||
|
@@ -359,7 +387,7 @@ preserve | |
} | ||
|
||
} | ||
|
||
|
||
gen stack_x = layer2 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
v 1.7 | ||
v 1.71 | ||
d 'SANKEY': A Stata package for Sankey plots | ||
d | ||
d Distribution-Date: 20231106 | ||
d Distribution-Date: 20240115 | ||
d | ||
d Asjad Naqvi | ||
d [email protected] | ||
|