BookmarkSubscribeRSS Feed
curious_guy
Calcite | Level 5

Hi There. 

 

I have this data, data A & B

curious_guy_0-1668049419766.png

curious_guy_1-1668049440654.png

I want to ask your expertise how to divide value from total_balance (Data A) to every var cell in data B for each year to get the percentage, so it will show like the picture below. 

curious_guy_2-1668049635037.png

I usually do this manually on excel and I want to improve this. 

 

here is my code 

generate Data A

proc tabulate data = data_a;
table year, total_balance;
var total_balance;
class year;

run;

generate Data B

proc tabulate data = lnsx3by;
table year, MOBx*balance;
var balance;
class year MOBx;
run;

 

Thank you for your help 

 

2 REPLIES 2
Tom
Super User Tom
Super User

Since you only posted pictures we have to make a lot of guesses at what data you actually have.

It sounds to me like you one dataset with two variables YEAR and TOTAL_BALANCE.

And a second dataset with YEAR, MOBX and BALANCE.

 

So it sounds like you just want to MERGE the two by YEAR and then DIVIDE the two numbers to make a percentage.

data want;
  merge b a ;
  by year ;
  percent = balance/total_balance.
  format percent percent6. ;
run;
curious_guy
Calcite | Level 5
Hi Tom. thank you for your answer. Understand that my question seems guessing for the reader. I've try with your code and understand your point. Thank you tom 🙂

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
  • 2 replies
  • 1079 views
  • 1 like
  • 2 in conversation