Hi all,
I'm new to STATA. I just started using it for the first time yesterday. I have some experience coding in C++ and IDL.
I have a small question related to inserting a variable in xlabel to automate a specific part of creating a histogram.
Currently, in xlabel I have to manually write the mean (see code below). I'd like to know how I can put in a variable which represents the mean.
It's a small thing, but I like to automate my code as far as possible because I eventually want to write a for loop to create many histograms.
I tried using r(mean) after running the summarize function (e.g. replacing 50 with r(mean)), but it didn't work...
Do you know an efficient way of solving my problem? Please ask if anything was unclear.
Thanks in advance for any help.
I'm new to STATA. I just started using it for the first time yesterday. I have some experience coding in C++ and IDL.
I have a small question related to inserting a variable in xlabel to automate a specific part of creating a histogram.
Currently, in xlabel I have to manually write the mean (see code below). I'd like to know how I can put in a variable which represents the mean.
It's a small thing, but I like to automate my code as far as possible because I eventually want to write a for loop to create many histograms.
I tried using r(mean) after running the summarize function (e.g. replacing 50 with r(mean)), but it didn't work...
Do you know an efficient way of solving my problem? Please ask if anything was unclear.
Thanks in advance for any help.
Code:
** from this I can get the mean manually sum hist_data ** Create histogram histogram hist_data, bin(20) start(0) xaxis(1 2) xlabel(50 "mean", axis(2) grid gmax)
Comment