DATA Step, Macro, Functions and more

Sum the values of a variable to get the result like a new variable

Reply
N/A
Posts: 0

Sum the values of a variable to get the result like a new variable

Hi all,

I'm quite new of Sas (I've finished my first traingin two weeks ago)....so I'm sorry if I write in the wrong section.
I have an issue with the sum of the observations of a variable: I would like to sum all the observations of a variable in order to get a final result to save in a new variable.
This is what I want but I don't know how....
May someone help me?
Thanks in advance
Super Contributor
Posts: 281

Re: Sum the values of a variable to get the result like a new variable

Posted in reply to deleted_user
PROC MEANS or PROC SUMMARY or PROC UNIVARIATE will provide you with the sum of a variable. The OUTPUT statement will provide the result in a SAS data set for you to use.
N/A
Posts: 0

Re: Sum the values of a variable to get the result like a new variable

Thank yoy very much! I used the proc univariate and now it works-->

proc univariate data=sasuser.PBZ_BCSI_Q2_2;
var New_weight;
output out=weight
sum=tot_weight;
run;

Now I'm gonna using "merge" to use the proc univariate result (sum) in some other operation inside my data set "sasuser.PBZ_BCSI_Q2_2.
Super Contributor
Posts: 673

Re: Sum the values of a variable to get the result like a new variable

Posted in reply to deleted_user
share an example of what you are looking for.
Ask a Question
Discussion stats
  • 3 replies
  • 127 views
  • 0 likes
  • 3 in conversation