π§ Final Day Plan β 8:30amβ12:20pm#
Note
Longer form examples
Theme: From Merge to Meaning to Graph
π 8:30β9:00 β Recap & Motivation#
Why we merge: join realities
Why we egen/by: summarize for clarity
Why we graph: show what we now believe
π 9:00β10:00 β Live Merge & Data Structuring#
clear
use transplants, clear
merge 1:1 fake_id using donors_recipients.dta
tab _merge
drop if _merge != 3
Then:
egen tag_group = tag(don_ecd gender)
egen group_mean_age = mean(age), by(don_ecd gender)
egen group_size = total(tag_group), by(don_ecd)
List example:
list don_ecd gender group_mean_age group_size if tag_group
π 10:00β11:00 β Survival Setup + KM Graph#
gen f_time = end_d - transplant_d
format transplant_d end_d %td
stset f_time, failure(died)
stsum
sts graph, by(don_ecd)
graph export survival.png, replace
Then if time permits:
stcox don_ecd age
π 11:00β11:30 β Bar + Line Overlay (tx_yr.dta)#
use tx_yr, clear
graph bar not_working, over(yr) ylab(0(50)250) ///
|| line total yr, lcolor(blue)
π¦ 11:30β12:00 β Overlay Scatter (gendered weight)#
use transplants, clear
twoway ///
(scatter rec_wgt_kg age if gender == 1, mcolor(blue)) ///
(scatter rec_wgt_kg age if gender == 2, mcolor(red)) ///
legend(order(1 "Male" 2 "Female"))
π§ͺ 12:00β12:20pm Lab Instructions#
Lab 5 Goal: Apply merge, egen, group stats β build clear graphs. Remind:
Label axes and variables
Export to
.png
Donβt forget
log using
π¦ One-Liner Summary for Students:#
Merge the files. Tag and summarize by group. Plot what matters. Export what you trust.