/* This is example of age caluculate wihtout to display
perfect days and years in output window */

data age;
retain dob "12jun2003"d now "24may2011"d;
age1=now-dob;
age=(now-dob)/365.25;
years=int(age);
days1=round((age-years)*365.25);
months=month(now)-1;

if days1 gt 30 and months in(12,10,8,6,4,2)then do;
month1=days1/30.4375;
month=int(days1/30.4375);
if day(now)=1 then days=1;
else days=round((month1-month)*30.4375)+1;
drop days1 month1 month;
end;

else if days1 gt 30 and months in
(1,3,5,7,9,11)then do;
month1=days1/30.4375;
month=int(days1/30.4375);
if day(now)=1 then days=1;
else days=round((month1-month)
*30.4375);
drop days1 month1 month;
end;

drop age age1;
proc print data=age;
format dob now date.;
run;

Answer Posted / muralavenu

Year and Day is fine. but Month is calculating from
current month onwords(i.e. ending to starting instead of
starting to ending). How to get rid of this problem. Plz
find out.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

please can you tell me that in companies sas work are doing by through sas coding or sas wizard ??

1662


What are the functions used for character handling?

644


I have a SCD Type 2 Dimention for Location In which A Sales Office in Having two Surrogate Keys just because of the change in it's Sales Group. SKey SalesGroup Sales Office BeginDate EndDate 280 SG1 SO1 01APR2000 01APR2010 281 SG2 SO1 02APR2010 31MAR2999 Now while loading the Fact, the Lookup ir returning SKey 280 for records before and after 01APR2010. I am not able to give WHERE condition in the Lookup Properties (TranDate between BeginDate and EndDate). Please help.

1697


how many types prompting framework can be broken down to? : Sas-bi

631


Hi Friends, Am Priya,new to your forum. am looking for Interview questions on SAS Platform Administration. I searched everywhere but I couldn't find them,please can anyone help me with complete interview questions normally everyone will face in the interviews on SAS Administration. am really facing problems in the interviews,am not able to answer any of their questions. I would really appreciate all your help if you can email the complete Interview Questions to priyafeb84@gmail.com Kindly awaiting for your reply with eager

1612






if the Id has more then two transcatiion then show the first observation, IF Id has only two observation then It show both the observation

1167


describe the interaction table in sas di? : Sas-di

594


Explain the difference between using drop = data set option in set and data statement?

682


Describe the function and untility of the most difficult SAS macro that you have written.

1726


how to do user inputs and command line arguments in sas?

2428


what is study design in while working with SAS? what are screening variables in SAS?

1680


what is the different between functions and procs that calculate the same simple descriptive statistics? : Sas programming

589


How to limit decimal places for the variable using proc means?

601


What is PROC in SAS?

604


List out some key concept of SAS

619