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
1 | 0 | 3 | 142 | 145 | 142 |
I want to join the sum from proc means to the main dataset T.
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;
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;
Thank you!
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.
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.