Dear colleagues,
I am currently facing what doesn't seem to be a great problem, but I am new to STATA and I'm not finding a proper automated solution. Basically, I imported several excel files which contained time series data to STATA, with their corresponding names being located at the end of the variable's name (i.e. "MonrningstarCategory202011", referring to the Morningstar Category each observation belonged to in November 2020). The problem comes with certain variables whose names are excessively long in origin (for instance, "NumberofShareholders202011"), as Stata crops them (I guess in order to fit the maximum length variable's names can have) and cuts the time-part of the variable (in this case 202011). Therefore, as the time part is what distinguishes variables among them, there end up being identical variable names, and Stata automatically gives them the name of their corresponding column (for instance, "AZ", "AB", "R"...). I will attach an image of an excel file exported from Stata so that you are better able to understand what is actually happening.
I want to rename all variables with their original name (which currently just appears as the label), without losing the time part. I have tried commands as renvarlab but they have not worked at all (maybe I did not use them properly). I wanted to have it done with loops or some semi-automated form.
Do any of you know how may I solve this? Thanks in advance!!!

I am currently facing what doesn't seem to be a great problem, but I am new to STATA and I'm not finding a proper automated solution. Basically, I imported several excel files which contained time series data to STATA, with their corresponding names being located at the end of the variable's name (i.e. "MonrningstarCategory202011", referring to the Morningstar Category each observation belonged to in November 2020). The problem comes with certain variables whose names are excessively long in origin (for instance, "NumberofShareholders202011"), as Stata crops them (I guess in order to fit the maximum length variable's names can have) and cuts the time-part of the variable (in this case 202011). Therefore, as the time part is what distinguishes variables among them, there end up being identical variable names, and Stata automatically gives them the name of their corresponding column (for instance, "AZ", "AB", "R"...). I will attach an image of an excel file exported from Stata so that you are better able to understand what is actually happening.
I want to rename all variables with their original name (which currently just appears as the label), without losing the time part. I have tried commands as renvarlab but they have not worked at all (maybe I did not use them properly). I wanted to have it done with loops or some semi-automated form.
Do any of you know how may I solve this? Thanks in advance!!!
Comment