egen: create derived variables in the browser

Use the implemented subset of egen functions for grouped, standardized, row-wise, and structural transformations.

Try the live demo View supported commands

Independent software. Not affiliated with, sponsored by, or endorsed by StataCorp LLC.

Runnable examples

import delimited "hsb2.csv", clear
egen mean_math = mean(math)
egen z_math = std(math)
egen score_mean = rowmean(read write math)
egen race_ses = group(race ses)

These examples create an overall mean, a standardized score, a row mean across three tests, and numeric IDs for combinations of race and ses.

Group-wise calculations

Supported by:, bysort:, or by() forms can make eligible aggregate functions operate within groups. Always sort and inspect a few groups when the grouping definition matters to the analysis.

Current limits

egen is a large command family, and only implemented functions should be treated as supported. The current engine covers functions including mean, std, rowmean, rowtotal, and group, but this is not the full official or community-contributed egen function ecosystem.

Run a small canonical example for every function on which your workflow depends.

Related guides

Try the workflow

Open the live project, inspect the existing do-file, and adapt the example above. No stats.camp account is required for the demo.

Open live demo