DATA Step, Macro, Functions and more

SAS Proc Report Subgroup

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

SAS Proc Report Subgroup

Let say that I Have a simple table that have four variables (Company, Profit_January, Profit_February, Profit_March).

I would like to display my report to be like this:

enter image description here

In which, the Profit_January, Profit_February, and Profit_March is under subgroup Profit. Is it achievable doing Proc Report?


Accepted Solutions
Solution
‎03-23-2016 04:59 AM
SAS Super FREQ
Posts: 8,743

Re: SAS Proc Report Subgroup

Hi: It looks like "Profit" isn't a variable, but is just a spanning header. What code have you tried already? What does your COLUMN statement look like right now with PROC REPORT. Have you tried to use a spanning header?

Something like:
COLUMN Company ('Profit' profit_jan profit_feb profit_mar);

(I know, they are not the variable names you originally showed, but I didn't want to run out of real estate.

cynthia

View solution in original post


All Replies
Solution
‎03-23-2016 04:59 AM
SAS Super FREQ
Posts: 8,743

Re: SAS Proc Report Subgroup

Hi: It looks like "Profit" isn't a variable, but is just a spanning header. What code have you tried already? What does your COLUMN statement look like right now with PROC REPORT. Have you tried to use a spanning header?

Something like:
COLUMN Company ('Profit' profit_jan profit_feb profit_mar);

(I know, they are not the variable names you originally showed, but I didn't want to run out of real estate.

cynthia
Occasional Contributor
Posts: 6

Re: SAS Proc Report Subgroup

Hi Cynthia,

 

Thank you! It works fine for me, one more question if you don't mind. I got my table from transposing another table. Hence the column name is not static, for example it can be profit_march, profit_april, profit_may instead of profit_january, profit_february, profit_may depending on the given parameter.

 

If that is the case how do I define the Column? 

 

Thanks!

Super User
Posts: 10,497

Re: SAS Proc Report Subgroup

If you transposed from a data set that had month as a variable you might be better off to go back to that and use month with a label of "Profit" as a column header. Sort order would probably be best to have month as the number of month and use a custom format to display the month's name so order=internal.

Or if you had actual date values use an appropriate format for a date.

Then you don't have to worry about changing numbers of months and adjusting a list of variables.

Super User
Posts: 9,676

Re: SAS Proc Report Subgroup

Try variable list method .
COLUMN Company ('Profit' profit_:  );
☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 274 views
  • 4 likes
  • 4 in conversation