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.
Please show us your data instead of describing it. Makes it much easier to provide a usable code answer 🙂
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;
@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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.