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!!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 928 views
  • 0 likes
  • 3 in conversation