BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User

Paige,

As your wish , but that is not easy, you need change the code according to the data.

 

data have;
input ID Code Date :anydtdte. Amount;
format date ddmmyy10.;
datalines;
1 0 31.01.2020 100
1 1 29.02.2020 80
1 2 31.03.2020 120
1 1 30.04.2020 75
2 2 31.01.2020 200
2 2 29.02.2020 150
2 4 31.03.2020 125
2 0 30.04.2020 230
3 1 31.01.2020 75
3 1 29.02.2020 65
3 3 31.03.2020 80
3 4 30.04.2020 90
4 0 31.01.2020 500
4 0 29.02.2020 350
4 1 31.03.2020 200
4 1 30.04.2020 100
;


options missing='0';
proc report data=have nowd  out=w;
    columns date code,amount total;
    define date/group;
    define code/across;
    define amount/analysis sum;
	define total/computed 'Total';
	compute total;
     total=sum(_c2_,_c3_,_c4_,_c5_,_c6_);
	endcomp;
run;
PaigeMiller
Diamond | Level 26

Thanks @Ksharp , but the documentation clearly indicates you can put a statistic keyword in the COLUMNS statement. So the explicit calculation via a compute block shouldn't be necessary.

 

Nevertheless, the code I posted a few minutes ago works only for SUM, I still can't get it to work for MEAN.

--
Paige Miller
PaigeMiller
Diamond | Level 26

@PaigeMiller wrote:

 

Nevertheless, the code I posted a few minutes ago works only for SUM, I still can't get it to work for MEAN.


Now it works with MEAN (and analogously for any other statistic SUM, P75, etc.)

 

proc report data=sashelp.class;
    columns sex ("Age" age,height ("Average" height=heightmean));
    define sex/group;
    define age/across ' ';
    define height/analysis mean;
    define heightmean/analysis mean format=6.1;
run; 

 

--
Paige Miller
Jay_Aguilar
Calcite | Level 5
Thank you, that is also an intersting way to do .

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 18 replies
  • 5105 views
  • 2 likes
  • 6 in conversation