Hi
Here i want employee retirement date from date_of_birth below find attachment of employee excel sheet
proc import datafile="/home/u35263349/My_Folder/Employee_Details.xlsx"
out=employee_info
dbms=xlsx;
quit;
data ds;
set employee_info;
if emp_dob >=60 then output;
proc print;
run;
There are some minor problems with your code:
What is emp_dob? If it is the date of birth, and was correctly read by sas, then use function intck to calculate the age in years.
@BrahmanandaRao wrote:
Please give solution
As long as you don't invest the time to provide data in usable form - @ballardw explained why posting excel files is not posting data - i can't provide any code, because i would have to make to many assumptions about types and values in your data, it is most likely that the code would not work with your data at all. Besides i mentioned the function intck, the docs have an example, you should be able to adept that to your needs. Maybe it is not the right function to use, but that depends on the data you have and what you are trying to achieve. Since you have not shown us the expected result, we play another guessing game.
@BrahmanandaRao wrote:
Hi
Here i want employee retirement date from date_of_birth below find attachment of employee excel sheet
proc import datafile="/home/u35263349/My_Folder/Employee_Details.xlsx" out=employee_info dbms=xlsx; quit; data ds; set employee_info; if emp_dob >=60 then output; proc print; run;
Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.
Rule(s) for creating the retirement date are what exactly?
Here is an example of incrementing a DOB to a date 40 years later.
data example; dob = '15Mar1955'd; retiredate= intnx('year',dob,40,'s'); format dob retiredate date9.; run;
Have you tested the code?
Logs says
NOTE: Invalid data for EMP_DOB in line 33 17-26. NOTE: Invalid data for EMP_DATE_OF_JOINING in line 33 27-35. REGEL: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 33 51123 Angela 22/07/1968 22/05/1990 Manager Mumbai 984511126 EMP_CODE=51123 EMP_NAME=Angela 2 EMP_DOB=. EMP_DATE_OF_JOINING=. EMP_DESIGNATION=anager Mumbai 9845111 EMP_CITY= EMP_MOBILE=. _ERROR_=1 _N_=1
And still no rule(s) for how to actually calculate retirement or show the result.
Some simple POSSIBLE rules:
At a specific calendar age. Show the data that age occurs. Or number of days or weeks or months or years until it occurs.
A specific number of years employed. Show the date that occurs on.
My retirement agency has something they call "Rule 90" for "full retirement benefits". Which is calculated as the date the Number of Years of Service (employed) plus calendar age in years = 90. Not a trivial exercise in programming; not horribly difficult but since you have to simultaneously increment two sets of dates, age and years of employment, not a one line code solution.
So, what would be your rule for calculating retirement and how do you want the solution to show?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.