## obtaining minor to major using date diffs?

Frequent Contributor
Posts: 97

# obtaining minor to major using date diffs?

hi,

I am providing a sample data .

1)I need the investor who attained the minor to major on 14/01/2012 ( i .e greater than equal to 18 years)

2)I should pick up the entire address from another database (have2) with the INVNAME?

data have1;

input name\$  dob DATE10.;

cards;

SHARMA  10/10/2010

TRISHA A 30/11/1992

TRISHA  30/11/1999

SANGHVI  30/05/2000

SANGHVI  26/03/1991

;

run;

data have2;

input INVNAME \$8.  STATE\$        ACNO\$;

cards;

SHARMA  UTTAR PRADESH 813120*****

TRISHA  GUJARAT 819173*****

TRISHA A GUJARAT 826162*****

SANGHVI  GUJARAT 826293*****

SANGHVI  GUJARAT 826313*****

;

run;

Super User
Posts: 23,774

## Re: obtaining minor to major using date diffs?

Posted in reply to allurai0412

Formula for Age :

`age = floor ((intck('month',birth,somedate) - (day(somedate) < day(birth))) / 12); `

proc sql;

create table want as

select invname, state, acno, dob, floor((intck('month', dob, '14Jan2012'd)-(day('14jan2012'd)<day(dob)))/12) as age

from have

join have2

on name=invname

where age>=18;

quit;

attained minor to major on and greater than equal on are two different classifications. Do you want everyone who turned 18 on that date or anyone who was older than 18 as of that date?

You can play around with the where clause to get what you want, and you may also need to modify the join (left/right/full) depending on your data.

```
1)I need the investor who attained the minor to major on 14/01/2012 ( i .e greater than equal to 18 years)
```
Frequent Contributor
Posts: 97

## Re: obtaining minor to major using date diffs?

hi

what's the logic behind the sub code day(somedate) < day(birth)))?

thanks

ALLU

Discussion stats
• 2 replies
• 137 views
• 4 likes
• 2 in conversation