Dear statalist
I am about to look at the frequency dist of several independent variables in my dataset, using the lengthy code similar to the example i have shown below.
In the example below, imagine I wanted do the analyses for headroom, reat_seat, trunk weight etc
For the past years, I have been copying everything into MSword, used search/replace "headroom" and change to "rearseat". And then pasted this new output into my (even lengthier) do file.
There must be a simpler way to run the same code on several variables?
I would be forever grateful for a tip on this!
I am using Stata/IC 14.2 for Mac
I am about to look at the frequency dist of several independent variables in my dataset, using the lengthy code similar to the example i have shown below.
In the example below, imagine I wanted do the analyses for headroom, reat_seat, trunk weight etc
For the past years, I have been copying everything into MSword, used search/replace "headroom" and change to "rearseat". And then pasted this new output into my (even lengthier) do file.
There must be a simpler way to run the same code on several variables?
I would be forever grateful for a tip on this!
I am using Stata/IC 14.2 for Mac
Code:
use http://www.stata-press.com/data/r14/autofull.dta, clear *Example of 3 IVs could be: headroom reat_seat trunk weight *name used in var and when naming graphs *transformations gen sqr_headroom =sqrt(headroom) gen l_headroom =ln(headroom) gen l10_headroom =log10(headroom) gen i_headroom =1/(headroom) *do they resemble Gaussian? dotplot headroom if price<15000 , ml(order) name(d1, replace) ytitle("raw") dotplot sqr_headroom if price<15000 , ml(order) name(d2, replace) ytitle("sqrt") dotplot l_headroom if price<15000 , ml(order) name(d3, replace) ytitle("ln") dotplot l10_headroom if price<15000 , ml(order) name(d4, replace) ytitle("log10") dotplot i_headroom if price<15000 , ml(order) name(d5, replace) ytitle("inv") qnorm headroom if price<15000 , ml(order) name(q1, replace) ytitle("raw") qnorm sqr_headroom if price<15000 , ml(order) name(q2, replace) ytitle("sqrt") qnorm l_headroom if price<15000 , ml(order) name(q3, replace) ytitle("ln") qnorm l10_headroom if price<15000 , ml(order) name(q4, replace) ytitle("log10") qnorm i_headroom if price<15000 , ml(order) name(q5, replace) ytitle("inv") swilk headroom if price<15000 swilk sqr_headroom if price<15000 swilk l_headroom if price<15000 swilk l10_headroom if price<15000 swilk i_headroom if price<15000
Comment