Hello everyone,
I am trying to create a loop so that I can add multiple variables for creating mean_var and median_var. However, this data isn't creating any variables; the collapsed_file is the same as my original data.
Thanks in advance!
I am trying to create a loop so that I can add multiple variables for creating mean_var and median_var. However, this data isn't creating any variables; the collapsed_file is the same as my original data.
Code:
use appended_data, clear // Define variables for loop (Renamed) local renamed_vars varA varB // Speaker-Interview Level Averages and Medians preserve foreach var of local renamed_vars { collapse (mean) mean_`var' = `var' /// (median) median_`var' = `var', /// by(interview_id speaker_num) } tempfile collapsed_file save `collapsed_file', replace restore
Comment