System variables

Next to the return and ereturn list, there also exists a creturn list which contains system values, directories, default settings, information on the current data and much more. This can be used for automatization.

clear all
sysuse census

creturn list


** Some examples of using the creturn list for automated processes:

// Use user name to set directory
if c(username)=="anna" cd "/Users/anna/ownCloud/Advanced Stata/Selbstlernkurs/4_Other material/Interaction with system"

// Use current date to keep track of changes
di "Last version: `c(current_date)'"
global date = date("`c(current_date)'","DMY")
global date: di %tdYYYYNNDD $date
// in one line:       global date: di %tdYYYYNNDD `= date("`c(current_date)'","DMY")'
save data_$date.dta, replace