BookmarkSubscribeRSS Feed
vraj1
Quartz | Level 8

I have a dataset like

Trial     treat1   treat2

123       23.2      34.2

234       78          87

 

Now i want a last column naming all with sum of the rows

Trial     treat1   treat2

123       23.2      34.2

234       78          87

all          101,2    121,2

 

Can any one help me in this

3 REPLIES 3
LinusH
Tourmaline | Level 20

PROC PRINT.

Data never sleeps
set_all__
Fluorite | Level 6

 

 

 

proc sql;
create table sum_row as
select
'all' as trial,
sum(treat1) as treat1,
sum(treat2) as treat2
from have;
quit;

proc append base=have data=sum_row;
run;

 

 

ballardw
Super User

I am always very leery of any inserted summary rows inside a data set. What happens if you run the same summary program later on the same data? Or you run a report procedure like Proc Report that generates summary totals. You have now included the summary into a new summary.

 

At a very minimum I would add an indicator variable to show that the row is indeed some sort of summary and the other rows aren't with appropriate label for the indicator.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 793 views
  • 0 likes
  • 4 in conversation