BookmarkSubscribeRSS Feed
kk13
Calcite | Level 5

I have longitudinal data of number of hospital visits for individuals from when they were ages 15 through 30.  I have counted the total number of visits at different age ranges (15-20, 21-25, 26-30, and 15-30).  Each individuals have different weights assigned at each age.  I would like to calculate the weighted average of visits at different age ranges.   Does it make sense to take the weights at age 30 (weight30) to take the weighted averages?  Or should I use weight20 to calculate the weighted average number visits 15-20 (visits1520), weight25 for visits2125, weight30 for visits2630, and weight30 for visits1530. 

 

 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Please show us your data instead of describing it. Makes it much easier to provide a usable code answer 🙂

kk13
Calcite | Level 5

Age1520 is the total number of visits from ages 15 through 20,...etc. 

 

data have;

input id age1520 age2125 age2630;

datalines;

 

1 7 8 3

2 4 10 5

3 7 13 2

4 5 15 6

5 4 11 2

;

data weights;

input id weights15-weights30;

datalines;

 

 

PaigeMiller
Diamond | Level 26

@kk13 wrote:

I have longitudinal data of number of hospital visits for individuals from when they were ages 15 through 30.  I have counted the total number of visits at different age ranges (15-20, 21-25, 26-30, and 15-30).  Each individuals have different weights assigned at each age.  I would like to calculate the weighted average of visits at different age ranges.   Does it make sense to take the weights at age 30 (weight30) to take the weighted averages?  Or should I use weight20 to calculate the weighted average number visits 15-20 (visits1520), weight25 for visits2125, weight30 for visits2630, and weight30 for visits1530. 

 


You are asking what the proper weighting scheme is for this data. This is not a question we can answer. We don't know what your weights are, how they were derived, and in general, we can't know what the proper weighting is because we are not familiar with the underlying problem. You are the one who needs to decide the proper weighting scheme, and then we can help you write the code.

--
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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 474 views
  • 1 like
  • 3 in conversation