BookmarkSubscribeRSS Feed
jeremy4
Quartz | Level 8

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.

 

BALANCE and MOVEMENT..PNG

3 REPLIES 3
Onizuka
Pyrite | Level 9
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 ;
Onizuka
Pyrite | Level 9

I delete my previous message because it was false, my solution is working now.

 

here the output :

 

Capture.PNG

PaigeMiller
Diamond | Level 26

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:

https://documentation.sas.com/?docsetId=proc&docsetTarget=p070bkysj4lkyun0zxj45n643q1i.htm&docsetVer...

--
Paige Miller

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1008 views
  • 1 like
  • 3 in conversation