Difference in percentage

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

Difference in percentage

Hi,

I need to compare 2 columns(A with B) values and find out the difference in % in next column I used Dif function but giving only count difference is any other function to identify difference in percentage.

ABC(Difference in %)
502040
1003070
15013510

I used below code

data one;

input A B;

cards;

50 20

100 30

150 135

;

run;

data Diff;

Set one;

c = (A- B);

run;


Accepted Solutions
Solution
‎08-04-2014 06:26 AM
Trusted Advisor
Posts: 1,203

Re: Difference in percentage

Hi,

If you are trying to display values in % then try this.

data one;
input A B;
cards;
50 20
100 30
150 135
;


run;

data Diff;
Set one;
c = (A-B)/A;
format c percent6.1;
run;

View solution in original post


All Replies
Valued Guide
Posts: 3,206

Re: Difference in percentage

When you want to work with percentages there must be reference value. With unclear definitions you will not get answers.   Answer=42  .  (the answer for the ultimtate question).

Percentages are often used with misleading expectations. Suppose you are profits are 100% (on original price) then the correction back new to old is 50% lose.

For the first row the absolute difference is 30 reference for 50  is 60%  for 20 that is 150% for an original 100 that is 30% for 70 (the sum) it is 43% for 35 (the mean) 85% . What answer do you like?  

---->-- ja karman --<-----
Contributor
Posts: 41

Re: Difference in percentage

Hi thanks for replay  I need like below out put difference in %.

ABC(Difference in %)
1002080
1003070
1006040
Valued Guide
Posts: 3,206

Re: Difference in percentage

then your reference is the A column ( ..   / A *100)...   Did you notice your values are already there?

---->-- ja karman --<-----
Solution
‎08-04-2014 06:26 AM
Trusted Advisor
Posts: 1,203

Re: Difference in percentage

Hi,

If you are trying to display values in % then try this.

data one;
input A B;
cards;
50 20
100 30
150 135
;


run;

data Diff;
Set one;
c = (A-B)/A;
format c percent6.1;
run;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 223 views
  • 0 likes
  • 3 in conversation