BookmarkSubscribeRSS Feed
SAS93
Quartz | Level 8

I a table:

  Year
  2016 2017 2018 2019 2020
Region Row_Percent Row_Percent Row_Percent Row_Percent Row_Percent
East 31.65 30.15 53.66 58.37 50.8
Middle 44.39 46.45 36.83 31.2 40.45
West 23.95 23.39 9.51 10.44 8.75

 

It's produced using this code:

Proc report data=year3_region nowd;
	Column	region YY4_DOB,Row_Percent dummyvar;
	Define	region / group;
	Define yy4_DOB / across;
	Define Row_Percent / display ;
	** Dummy Var to help with formatting;
	Define dummyvar / computed noprint ;
		compute dummyvar;	dummyvar = 1;	endcomp;
Run;

The Row_percent comes from a previous crosstab output I retrieved. 

 

If possible, Iwant to add a new column at the end that represents the average of that row_percent across the 5-year period for each region. I've tried a few different examples I've found online, but none of them have worked. What's the best way to do this?

2 REPLIES 2
ballardw
Super User

If the denominator used in calculating the percent of each column is not exactly the same, or at least pretty close to identical, then the average of percentage is misleading at best and an out right lie for meaning at worst.

 

So, how similar are the denominators involved?

 


@SAS93 wrote:

I a table:

  Year
  2016 2017 2018 2019 2020
Region Row_Percent Row_Percent Row_Percent Row_Percent Row_Percent
East 31.65 30.15 53.66 58.37 50.8
Middle 44.39 46.45 36.83 31.2 40.45
West 23.95 23.39 9.51 10.44 8.75

 

It's produced using this code:

Proc report data=year3_region nowd;
	Column	region YY4_DOB,Row_Percent dummyvar;
	Define	region / group;
	Define yy4_DOB / across;
	Define Row_Percent / display ;
	** Dummy Var to help with formatting;
	Define dummyvar / computed noprint ;
		compute dummyvar;	dummyvar = 1;	endcomp;
Run;

The Row_percent comes from a previous crosstab output I retrieved. 

 

If possible, Iwant to add a new column at the end that represents the average of that row_percent across the 5-year period for each region. I've tried a few different examples I've found online, but none of them have worked. What's the best way to do this?


 

PaigeMiller
Diamond | Level 26

Compute the average for each row before you get to PROC REPORT, so now you have a data set which has the yearly percents and another piece of data which has the average percents. Take into account the warning from @ballardw to compute the average percent properly, accounting for differences in the denominator each year.

--
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
  • 2 replies
  • 434 views
  • 0 likes
  • 3 in conversation