Adding variables in Stata and then dividing by a number is giving unexpected results -


i trying calculate z-scores creating variable d 3 other variables, namely a, b, , c. trying generate d : d= (a-b)/c reason when it, produces large numbers. when did (a-b) did not should have when calculated hand, instead of -2, -105.66.

variable 'long' , variable b 'float', not sure if reason? stata syntax is:

gen zscore= (height-avheight)/meansd 

did not work.

you confusing scalars , variables. here's solution (chop off first 4 lines , replace x height fit calculation code):

// example data clear set obs 50 gen x = runiform()  // summarize qui su x // store scalars sca de mu = r(mean) sca de sd = r(sd)  // z-score gen zx = (x - mu) / sd su zx 

x , z-score zx variables take many values, whereas mu , sd constants. might code constants in stata using scalars or macros.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -