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

I calculated the sum of all the variables using proc means and not sure how to  combine them with the main dataset.

 

Given dataset T

ID  var1 var2 var3
1  20      30     52
2  80    20     65
3  42    95     25

 

Want dataset:

ID  var1  var2  var3
1    20    30     52
2    80   20     65
3   42    95    25
Tot 142 145 142

 

OUTPUT FROM PROC MEANS

Obs _TYPE_ _FR   VAR1 VAR2 VAR3                
103142145142        

 

 

I want to join the sum from proc means to the main dataset T.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

That's not really a good idea. If you want totals, you should use a reporting procedure such as PROC PRINT or PROC REPORT or TABULATE. It's too easy to mix up the totals with the data later on. 

 

Anyways, just append the data in, if you used the same variable names. If not, you need to rename them to match and append it.

 

data want;

set have totals;

run;

View solution in original post

2 REPLIES 2
Reeza
Super User

That's not really a good idea. If you want totals, you should use a reporting procedure such as PROC PRINT or PROC REPORT or TABULATE. It's too easy to mix up the totals with the data later on. 

 

Anyways, just append the data in, if you used the same variable names. If not, you need to rename them to match and append it.

 

data want;

set have totals;

run;
Kalai2008
Pyrite | Level 9

Thank you!

 

 

sas-innovate-2024.png

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.

 

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
  • 2 replies
  • 691 views
  • 0 likes
  • 2 in conversation