data have;
length Status $25.;
input Status cnt;
return;
datalines;
Tot_pop 10
Curr 5
_30_day 1
Paid 4
;run;
Status | cnt |
Tot_pop | 10 |
Curr | 5 |
_30_day | 1 |
Paid | 4 |
Is there a way to calculate the percentage change using Tot_Pop as the base line. Idea is to divide Curr/Tot_pop and show results on Curr row, then _30_day/tot_pop and show on _30_day row?
Its really hard to generalize from your example
If tot_pop is the sum of the other CNT values, then you don't need it. (Is it always going to be the sum of the other CNT values?)
But assuming it is the sum of the other CNT values, get rid of the tot_pop line, delete it from your data set, and then run PROC FREQ to get your percentages.
@Q1983 wrote:
data have;
length Status $25.;
input Status cnt;
return;
datalines;
Tot_pop 10
Curr 5
_30_day 1
Paid 4
;run;
Status cnt Tot_pop 10 Curr 5 _30_day 1 Paid 4
Is there a way to calculate the percentage change using Tot_Pop as the base line. Idea is to divide Curr/Tot_pop and show results on Curr row, then _30_day/tot_pop and show on _30_day row?
I would call this a good example of why not to include summary data in data if Tot_pop is supposed to be the sume of Curr, _30_day and Paid. Especially if you calculated it previously.
One take on what I think is similar to what you want:
data have; length Status $25.; input Status cnt; return; datalines; Tot_pop 10 Curr 5 _30_day 1 Paid 4 ; run; proc tabulate data=have; where status ne 'Tot_pop'; var cnt; class status; table status all='Tot_pop', cnt *(sum pctsum) ; run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.