Search code examples
stata

Applying one equation into values of multiple variables (Stata)


I have several variables expressed differently with the following values as an example.

I want to multiply all values where the value is expressed as a ratio/proportion (e.g. unemployment_inc) by 100.

unemployment_inc   lfp_gender       unemployment_gender     lfp_inc
.2335658           17.35                  83.6            .3786077
.2335658           17.35                  83.6            .3786077
.2335658           17.35                  83.6            .3786077

I want the data to eventually look as follows:

unemployment_inc   lfp_gender       unemployment_gender     lfp_inc
 23.3              17.35                  83.6                37.8
 23.3          17.35                      83.6                    37.8
 23.3          17.35

Solution

  • local vars_proportion unemployment_inc lfp_inc
    foreach var of varlist `vars_proportion' {
        replace `var' = `var' * 100
    }