BookmarkSubscribeRSS Feed
Gladis6680
Obsidian | Level 7

Hi there,

I have written this code for a simple proc means 

proc means data=have SUM stackodsoutput;
var E F;
class A B C D;
run;

and I am getting this 

ABCDVariableSum
YellowYesItalyCoffeeE$10
    F3
YellowYesLondonMilkE$100
    F3
GreenYesIrelandWhole MilkE$25
    F3

 

what I would like is 

ABCDEF
YellowYesItalyCoffe$103
YellowYesLondonMilk$1003
GreenYesIrelandWhole Milk$253

 

to have the var variables side by side instead of one below the other. Is that possible. 

I would appreciate your help.

Thanks

7 REPLIES 7
Reeza
Super User
STACKODS affects the tables not the displayed output. I'm not aware of a way to get that output in PROC MEANS but you could use PROC TABULATE or REPORt if you wanted. Or you can pipe your results from PROC MEANS to a table and print that.

It all depends on what you're doing this for and the next steps.
Gladis6680
Obsidian | Level 7

Thank you! Let me try PROC TABULATE OR PROC REPORT

Ksharp
Super User

You missed option NWAY ,since you are using CLASS.

 

proc means data=have SUM stackodsoutput  NWAY;

Gladis6680
Obsidian | Level 7

Thank you !

I have used PROC REPORT to get the table in the format that I wanted

 

proc report data=have;
column A B C D E F;

define A/group;

define B/group;

define C/group;

define D/group;

define E/analysis sum;

define F/analysis sum;

run;

But I would like the E and F variables in the descending order, is there a way to do that.

Thank you very much!

Reeza
Super User
I believe there's an ORDER option on the DEFINE statement.
Ksharp
Super User

It is interesting. Looks like ORDER= option in PROC REPORT is not working . Try PROC SQL.

 

proc sql;
select age,sum(weight) as sum
 from sashelp.class
  group by age
   order by 2 desc;
quit;
Tom
Super User Tom
Super User

@Gladis6680 wrote:

Thank you !

I have used PROC REPORT to get the table in the format that I wanted

 

proc report data=have;
column A B C D E F;

define A/group;

define B/group;

define C/group;

define D/group;

define E/analysis sum;

define F/analysis sum;

run;

But I would like the E and F variables in the descending order, is there a way to do that.

Thank you very much!


How can they both be descending?

Do you mean you want it descending by E and then within the value of E descending by F?

You probably need to summarize first and then make a report.

proc summary nway data=have ;
 class a b c d;
 var e f ;
 output out=summary sum= ;
run;
proc sort data=summary ;
  by descending e descending f;
run;
proc print data=summary;
  var a b c d e f;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1380 views
  • 1 like
  • 4 in conversation