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

Hi everyone,

I'm not able to make a summary of columns with proc report  (or I can't find the sintax of code sas to make a summry of colomuns) .

for example, I have this data set:

SEX COD  VAL1  VAL2

M     1          12         2

F     3           14         2

M     2          12         3

and I would like to create a report like this:

SEX         COD        VAL1    VAL2     VAL1+VAL2

M               1              12        2           14

                  2              12        3           15

F                3              14        2            16

is there one way in proc report to summarize the column?

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Sure . Easy for proc report.

data have;
input SEX $ COD  VAL1  VAL2     ;
cards;
M     1          12         2
F     3           14         2
M     2          12         3
;
run;
proc report data=have nowd out=x;
column sex cod VAL1 VAL2 var1_var2;
define sex/group;
define cod/display;
define VAL1/display;
define VAL2/display;

compute var1_var2;
var1_var2=sum(VAL1,VAL2);
endcomp;
run;

Xia Keshan

View solution in original post

3 REPLIES 3
mohamed_zaki
Barite | Level 11

Look to me just restructure not summary

data have;

input SEX $ COD  VAL1  VAL2;

cards;

M     1          12         2

F     3           14         2

M     2          12         3

;

run;

proc sort data=have;

by descending sex Cod;

run;

data want ;

set have;

by descending Sex;

if ~(first.Sex) then Sex="";

TOT=VAL1+VAL2;

run;

Ksharp
Super User

Sure . Easy for proc report.

data have;
input SEX $ COD  VAL1  VAL2     ;
cards;
M     1          12         2
F     3           14         2
M     2          12         3
;
run;
proc report data=have nowd out=x;
column sex cod VAL1 VAL2 var1_var2;
define sex/group;
define cod/display;
define VAL1/display;
define VAL2/display;

compute var1_var2;
var1_var2=sum(VAL1,VAL2);
endcomp;
run;

Xia Keshan

Rakeon
Quartz | Level 8

Thank you!!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 3 replies
  • 1374 views
  • 0 likes
  • 3 in conversation