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
// see https://www.statalist.org/forums/forum/general-stata-discussion/general/33124-adding-other-data-as-a-label-to-bar-graph | |
sysuse census, clear | |
collapse (sum) pop pop5_17, by(region) | |
generate pr_5_17 = round(pop5_17/pop, 0.01)*100 | |
replace pop = pop/1000000 | |
rename pop pop_millions | |
graph bar (asis) pop_millions, over(region) ytitle("Population (In Millions)") blabel(bar) | |
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
sysuse bpwide, clear | |
bys agegrp : egen bldps_m = mean(bp_after) | |
keep agegrp bldps_m | |
duplicates drop | |
rename (bldps_m agegrp) (y x) | |
sum y | |
local plot_min = r(min)*0.97 | |
tw (sc y x) /// |
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
// label all weeks so that we know which week | |
// 2020 | |
local clearall | |
cap label drop week_lab20 | |
cap label drop week_lab21 | |
local i1 = tw(2020w1) | |
local i2 = tw(2020w52) | |
local j = 1 | |
forvalues i = `i1'/`i2'{ | |
label define week_lab `i' "20week`j'", add |
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
// label vars using 1st row, then drop 1st row | |
foreach var of varlist * { | |
label variable `var' "`=`var'[1]'" | |
replace `var'="" if _n==1 | |
} | |
drop in 1 | |
// wrap into a program | |
cap program drop mapvalues | |
program define mapvalues | |
syntax varlist, a(string) b(string) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.