Good afternoon,
I have a question concerning standardization per month for multiple variables. I am using panel data for a financial asset pricing model, and what I would like to do is create standardized values for a number of variables (ME, BTM, etc.) per month. Meaning I would like to standardize the variables ME, BTM, etc. for january 1963, february 1963, etc., all the way up to december 2013. The time variable is simply called 'time' and has the following format: YYYYmM (e.g. 1962m7).
I have tried to solve this issue by using the egen command -by time: egen std_ME = std(log_ME)-, however this gives the following error: "egen ... std() may not be combined with by". Furthermore, even if this did work, I would have to manually repeat the process for all variables (which however is not a very big issue, thanks to the relatively low number of variables needed to standardize).
Also, I have found the following script (which I found on Statalist):
Which I have unsuccessfully tried to edit to create standardized values, instead of standard deviations for my own data:
I would like to stress that I have some very basic knowledge of Stata, and little or no programming experience, so my question might be vague/unclear. If needed, I am more than happy to supply additional information.
Thanks in advance, Martin
I have a question concerning standardization per month for multiple variables. I am using panel data for a financial asset pricing model, and what I would like to do is create standardized values for a number of variables (ME, BTM, etc.) per month. Meaning I would like to standardize the variables ME, BTM, etc. for january 1963, february 1963, etc., all the way up to december 2013. The time variable is simply called 'time' and has the following format: YYYYmM (e.g. 1962m7).
I have tried to solve this issue by using the egen command -by time: egen std_ME = std(log_ME)-, however this gives the following error: "egen ... std() may not be combined with by". Furthermore, even if this did work, I would have to manually repeat the process for all variables (which however is not a very big issue, thanks to the relatively low number of variables needed to standardize).
Also, I have found the following script (which I found on Statalist):
Code:
levels class, local(levels) gen std = . foreach l of local levels { qui sum mpg if class == `l' qui replace std = r(sd) if class == `l' }
Which I have unsuccessfully tried to edit to create standardized values, instead of standard deviations for my own data:
Code:
levels time, local(levels) gen std_ME = . foreach l of local levels { qui sum log_ME if time == `l' qui replace std = r(std) if time == `l' }
I would like to stress that I have some very basic knowledge of Stata, and little or no programming experience, so my question might be vague/unclear. If needed, I am more than happy to supply additional information.
Thanks in advance, Martin
Comment