Desktop productivity for business analysts and programmers

Keep column name when summarizing

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Keep column name when summarizing

Perhaps this is a minor complaint, but I often find myself changing the names of columns after I set a summary method.  Is there a way to prevent the column name from changing from COLUMN_NAME to SUM_of_COLUMN_NAME?

 

While I believe I have thouroughly searched through the setting, I hold on to hope that I have overlooked it.

 

Thanks,

Ryan


Accepted Solutions
Solution
‎12-13-2016 05:07 AM
Grand Advisor
Posts: 17,345

Re: Keep column name when summarizing

Query builder is straight forward, when summarizing you have a field that says Column Name that you can type whatever you want into it, as long as it's a valid name. I don't think there's a default way to specify it to stay the same variable.

 

delete column name.JPG

 

The code override is relatively straightforward, as long as you're only calculating one statistic (ie mean/sum) it automatically saves with the same name. You do have to list the variables but you can use variable shortcuts.

 

proc means data=sashelp.class noprint;
var age weight height;
output out=want mean=;
run;

View solution in original post


All Replies
Grand Advisor
Posts: 17,345

Re: Keep column name when summarizing

Which Task exactly are you using?

 

I'm not sure there's a point and click mechanism, but I know for certain you can override this with code.  

 

You'll find EG will get you there 90%, the remaining 10% is code Smiley Happy

Occasional Contributor
Posts: 15

Re: Keep column name when summarizing

This is in a simple query builder, but I would happily use another task if it would avoid the issue. I absolutely can override it with code, but was hoping to avoid that. In this case, I am aggregating 27 variables and would prefer to not type it out.
Solution
‎12-13-2016 05:07 AM
Grand Advisor
Posts: 17,345

Re: Keep column name when summarizing

Query builder is straight forward, when summarizing you have a field that says Column Name that you can type whatever you want into it, as long as it's a valid name. I don't think there's a default way to specify it to stay the same variable.

 

delete column name.JPG

 

The code override is relatively straightforward, as long as you're only calculating one statistic (ie mean/sum) it automatically saves with the same name. You do have to list the variables but you can use variable shortcuts.

 

proc means data=sashelp.class noprint;
var age weight height;
output out=want mean=;
run;
Occasional Contributor
Posts: 15

Re: Keep column name when summarizing

Fantastic, that takes 50 lines of PROC SQL down to 5 lines of PROC MEANS.  

 

I was not aware of variable lists, they work perfectly in this scenario.

 

Thanks for your help.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 213 views
  • 0 likes
  • 2 in conversation