Help using Base SAS procedures

proc report summary of columns

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

proc report summary of columns

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?


Accepted Solutions
Solution
‎10-25-2014 08:39 AM
Super User
Posts: 10,041

Re: proc report summary of columns

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


All Replies
Super Contributor
Posts: 490

Re: proc report summary of columns

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;

Solution
‎10-25-2014 08:39 AM
Super User
Posts: 10,041

Re: proc report summary of columns

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

Contributor
Posts: 49

Re: proc report summary of columns

Thank you!!

🔒 This topic is solved and locked.

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

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