Hello. I frequently use Proc Means and the following code, which was working, is now giving me the following warning:
NOTE: Variable MARKET_EQUITY_RATIO_PD__StdDev already exists on file DSTATS.MARKET_BLOOMBERG_DAILY_C_D, using MARKET_EQUITY_RATIO_PD__StdDev2 instead.
I have several variables that begin with that prefix (MARKET_EQUITY_RATIO_PD), and each one is giving me this note. However, it is only happening with the STDDEV variables that it is naming automatically. My variables aren't more than 23 characters long (before appending _STDDEV).
Any thoughts on what might be causing this problem?
%MACRO CREATE_DISTRIBUTION_DATA(INLIB = , DATASET_NAME = , FIELDS = );
PROC MEANS NOPRINT DATA = &INLIB..&DATASET_NAME.;
CLASS TICKER;
VAR &FIELDS.;
OUTPUT OUT = DSTATS.&DATASET_NAME._D
N(&FIELDS.) =
NMISS(&FIELDS.)=
P50(&FIELDS.)=
MEAN(&FIELDS.)=
P10(&FIELDS.)=
P25(&FIELDS.)=
P75(&FIELDS.)=
P90(&FIELDS.)=
STD(&FIELDS.)=
MAX(&FIELDS.)=
MIN(&FIELDS.)=
/AUTOLABEL AUTONAME;
RUN;
%MEND CREATE_DISTRIBUTION_DATA;
I found that when I shrunk the name of "Market_Equity_Ratio..." variables to "Mkt_Equity_Ratio...", the code works. Even though the original fields, when appended with _STDDEV, wouldn't be 32 characters long (which I thought was the limit), the fields were getting truncated. Anyway, it works with a shorter field name now. Perhaps there is some overhead when autoname is applied that is reserved for possible duplicate field names (even though I didn't have any in this case).
Thanks for taking a look.
Can you post a proc contents on your original dataset?
Yes- here is the proc contents output.
I don't have SAS at home so can't view that...
Sorry. Here is an Excel file.
Double check the fields in your list, that will happen if the field is listed twice.
I don't see any duplicates, unfortunately. And if so, wouldn't that happen for all the variables that are created automatically, and not just the STDDEV ones?
Why can't you just show us &FIELDS.
Notice that the last letter of your variables are being removed before _STDDEV is appended for the new name. So it is not duplicates created by you but by PROC MEANS. Now how do we fix it.
I found that when I shrunk the name of "Market_Equity_Ratio..." variables to "Mkt_Equity_Ratio...", the code works. Even though the original fields, when appended with _STDDEV, wouldn't be 32 characters long (which I thought was the limit), the fields were getting truncated. Anyway, it works with a shorter field name now. Perhaps there is some overhead when autoname is applied that is reserved for possible duplicate field names (even though I didn't have any in this case).
Thanks for taking a look.
Seems to be statistics with names that are 6 characters long. I would look to another output option perhaps ODS OUTPUT with the STACKODS proc statement option..
I've seen this before, where the proc takes only 20 or so characters for the name and then truncates it. There's an option to fix it but I can't remember what it is
Myra first pointed out this difficulty of /AUTONAME creating non-unique names when the stat-name is appended.
There are two SASGF presentations on %BETTER_MEANS macro approaches.
1 used a OUTPUT statement for each statistic and "merged" them after.
2 renamed with VARNUM which is short enough to suffer the widest statistic name appended.
Should be quick to find at www.lexjansen.com
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.