在Excel的纵向数据库中找出一个人有多少个较老的兄弟姐妹 [英] Finding out how many older siblings an individual has in a longitudinal database in excel

查看:47
本文介绍了在Excel的纵向数据库中找出一个人有多少个较老的兄弟姐妹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据如下:

  • id--家庭编号--生日--收集日期
  • 1---56----86年3月2日-----1997
  • 1---56----86年3月2日-----1998
  • 2---56----82年8月30日-----1997
  • 2---56----1998年8月30日-----1998
  • 3---48----90年9月1日-----1997
  • 3---48----90年9月1日-----1998
  • 4---48----91年10月15日-----1997
  • 4---48----1998年10月15日-----1998

数据库是纵向的.身份证号代表个人,而家庭号代表遗传亲属.我想做的是创建一个新行,计算每个人拥有的同龄兄弟姐妹的数量.所以本质上,我想做的是,如果x是该人的生日,y是同一家庭中其他人的生日,则对于以后的每个y,都要添加一个,对于任何较早的y,请不要添加任何东西.

The database is longitudinal. The id number represents an individual while the family number represent genetic kinship. What I would like to do is make a new row that calculate the number of older siblings each individual has. So essentially what I would like to do is if x is the birthdate of the individual and y is the birthday of other individuals within the same family then for every later y add one and for any earlier y don't add anything.

是否有办法将其应用于每个人?我的数据库很大.它大约有30个人,每个人都有13年的数据.

Is there a way to do this and apply it to every individual? My database is large. It has about 30 individuals with 13 years of data for each.

推荐答案

假设您的数据在A到D列中,则可以在E2中添加此公式以获取所需的结果

Assuming your data is in columns A to D you could add this formula in E2 to get the required results

= SUMPRODUCT((((B $ 2:B $ 10 = B2)*(C $ 2:C $ 10< C2))/COUNTIF(A $ 2:A $ 10,A $ 2:A $ 10&;"))

您需要一个这样的公式来避免重复计算个人有多个条目的情况.它依靠A列中的ID为数字-如果不是这种情况,那么我可以调整公式以起作用.

You need such a formula to avoid double counting where individuals have more than one entry. It relies upon the ID in column A being numeric - if that isn't the case then I can adjust the formula to work.

注意:该公式只是计算年龄较大的家庭成员-我看不出如何保证他们是兄弟姐妹,难道他们不是母亲,叔叔或堂兄弟等吗?

Note: the formula is simply counting family members who are older - I don't see how you can guarantee that they are siblings, could they not be mothers, uncles or cousins etc.?

如果将公式应用于大量行,则该公式可能会变慢,因此,如果您按族对数据进行排序,则可以对公式的应用方式有所创新,例如如果每个家庭的最大记录数是200,则只需要在有限范围内查找的公式即可,例如每个方向200行

The formula can be slow if applied to a large number of rows, so if you have data sorted by family you can be creative in how it is applied, e.g. if maximum number of records per family is 200 you only need formulas that will look within a limited range, e.g. 200 rows in each direction

这篇关于在Excel的纵向数据库中找出一个人有多少个较老的兄弟姐妹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆