BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bkq32
Quartz | Level 8

I'm running a variable fit_msr_shldr_wst_sml_b_r_f through PROC MEANS and want it to output the 25th and 75th percentiles as fit_msr_shldr_wst_sml_b_r_f_p25 (31 chars) and fit_msr_shldr_wst_sml_b_r_f_p75. Why is the name being truncated and coming out as fit_msr_shldr_wst_sml_b_r__p25 (30 chars)? I know it's not an ideal variable name, but any help would be appreciated.

 

 

data have;
input fit_msr_shldr_wst_sml_b_r_f;
cards;
4
9
9
8
2
4
;
run;


proc means data=have nway noprint;
var fit_msr_shldr_wst_sml_b_r_f;
output out=temp0 P25= P75= / autoname;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
Just an educated guess that SAS needs to confirm...

When the software sees AUTONAME, it doesn't try to parse your code to see which statistics you want. Instead it presumes you might want to add the longest possible suffix (_range) and defines the prefix accordingly. The advantage: if you run AUTONAME twice with different statistics each time, you get the same prefix both times.

View solution in original post

6 REPLIES 6
ed_sas_member
Meteorite | Level 14
Hi @bkq32
Unfortunately, the maximum possible length for variable names is set to 32 in SAS, whatever the VALIDVARNAME option you use.
Maybe you could define some rules / naming conventions and document them for your dataset so that you still have meaningful variables. Why don’t you set labels for example ?
Best,
bkq32
Quartz | Level 8

Hi @ed_sas_member , If I'm not mistaken, the new variable name I'm trying to make would only be 31 characters, so I'm confused as to why it's being truncated

ed_sas_member
Meteorite | Level 14

Hi @bkq32 

As highlighted by @Astounding, SAS acts as if it has to put the largest keyword suffix while having less than 32 characters. To avoid this truncation, you can specify the desired name in the "keyword =" option and remove "autoname" (but you will loose the "flexibility" of the program)

 

proc means data=have nway noprint;
var fit_msr_shldr_wst_sml_b_r_f;
output out=temp0 P25=fit_msr_shldr_wst_sml_b_r_f_p25 P75=fit_msr_shldr_wst_sml_b_r_f_p75;
run;

Best,

 

bkq32
Quartz | Level 8
@ed_sas_member Thanks for letting me know how to work around that. I'll give that a shot
Astounding
PROC Star
Just an educated guess that SAS needs to confirm...

When the software sees AUTONAME, it doesn't try to parse your code to see which statistics you want. Instead it presumes you might want to add the longest possible suffix (_range) and defines the prefix accordingly. The advantage: if you run AUTONAME twice with different statistics each time, you get the same prefix both times.
bkq32
Quartz | Level 8
@Astounding That makes sense - thank you!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 3243 views
  • 1 like
  • 3 in conversation