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?
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
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;
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
Thank you!!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.