I made the program to have a unique argument, "outcomes", and then I insert the first argument for the code as a local containing two variables, "x" and "y".
The code only produces x_post_std instead of also producing y_post_std.
I checked the program arguments section of the help file, but it had no information about inputting a local as an argument.
Code:
cap program drop test program test * Arguments: components and covariates args outcomes { * Step 1: Standardize variables foreach var in `outcomes' { di "`var'" * Create standardized versions cap drop `var'_post_std sum `var' gen `var'_post_mean = r(mean) gen `var'_post_sd = r(sd) gen `var'_post_std = (`var' - `var'_post_mean) / `var'_post_sd drop `var'_post_mean `var'_post_sd } } end clear set obs 20 gen x = rnormal() gen y = rnormal() local variables "x y" test `variables'
0 Response to Local list of variables as argument of program
Post a Comment