Hi,
Can someone please provide me with the code (the dataset: data=APRIL_PROJECT) so that I can see the sum of the 'BALANCE' variable ('BALANCE' is a numeric variable) that belongs to each of the categories in the 'MOVEMENT' variable ('MOVEMENT' is a character variable) i.e. there would be a table that shows that the sum/total balance would be 700 for '1 to 2' (300+400) and 450 for '2 to 1' (200+250) etc. Thanks.
Data have ;
format balance 3. movement $6. ;
input balance movement ;
cards;
500 1_to_1
300 1_to_2
200 2_to_1
500 2_to_2
400 1_to_2
250 2_to_1
125 3_to_1
600 3_to_2
350 3_to_1
;
run ;
Proc sql ;
create table want as
select sum(balance) as sum, movement
from have
group by movement ;
run ;
I delete my previous message because it was false, my solution is working now.
here the output :
PROC MEANS/PROC SUMMARY was designed to do things like this, and is a basic fundamental SAS tool that (in my opinion) everyone should know. Example is here:
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.