03-05-2013 01:10 PM
I have a file with over 43000 unique rows which has a variable called model, I would like to get the average of this variable model for every fifth row.
I also have the file number indexed from 1 to 43000 but I am stuggling to get it to average it. I would even appreciate help with how to code every row into the same group by creating a new headin as then I could get the means by selecting unique group.
The file currently looks like;
position model n
483_1 0.1234 1
678_1 0.2345 2
876_1 0.1456 3
03-05-2013 01:28 PM
I'm not sure I understand the question fully but would something like this do what you want :
proc means data=MyData(where=(mod(n,5)=0));
03-05-2013 01:37 PM
I think we are all getting to the same point ... but here is my version:
if n = 1 then cat = 0;
group = mod(n,5);
if group = 1 then cat + 1;
the group variable is basically providing an indicator for every 5th observation. The cat variable is categorizing the group of 5 observations (1-5 cat 1 , 6 - 10 cat2 , etc...).
I wasnt clear if you are average the five observations (average obs 1 through 5, 6 through 10, etc... which would be over 8000 averages) or eliminate all but every 5th obs and average those obs for an outcome of one number.
Anyway .. hope this helps!
03-06-2013 09:27 AM
Thanks to everyone for their help, that worked perfectly!first time posting in a forum and was great to get such answers!
Need further help from the community? Please ask a new question.