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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 464 views
  • 1 like
  • 3 in conversation