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 2025: Call for Content

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!

Submit your idea!

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