Suppose you have a company SAS data set EMPLOY which contains, among other variables, EMP_NUM (employee number) and DATEHIRE (date of hire).You want to know how many years each employee has worked.One approximate method is to count how many year intervals have passed between the date of hire and the current date.The SAS function INTCK can be used to count how many times the period of employment has entered a new year (i.e. how many January Ist's have passed).This is accomplished using the following code:
Example
DATA NEW_EMP;Using 'YEAR' for the first argument of the INTCK function gives you the number of times a yearly boundary has passed.For example,if an employee were hired on November 3, 1993, and the value for CURRENT is February 1,1994, the program above would set WORK_YRS equal to 1 since there is one yearly boundary (January 1st) between November 3, 1993, and February 1, 1994. If an employee were hired on January 2, 1994, and the value for CURRENT is December 31,1994, the value of WORK_YRS would be 0,even though the employee had worked almost a full year.
Be cautious when using these functions and interpret your results very carefully.If you want to count the number of months between the current month and the month of hire you can use the INTCK function with MONTH as the appropriate interval.In general, the code to determine the number of months between the DATEHIRE date and the CURRENT date is:
WORK_MON=INTCK ('MONTH',DATEHIRE,CURRENT);In the first case where the date of hire is 11/3/93 and the CURRENT date is 2/1/94,the calculation gives you 3 (you have passed 3 month boundaries: Dec., Jan., and Feb.).
|
|
SAS Programming Related Tutorials |
|
---|---|
SASS (Syntactically Awesome Style sheets) Tutorial | R Programming language Tutorial |
SAS Programming Related Interview Questions |
|
---|---|
Logistics Interview Questions | SAS Programming,SQL server Interview Questions |
Clinical SAS Interview Questions | SASS (Syntactically Awesome Style sheets) Interview Questions |
SQL Server Analysis Services (SSAS) Interview Questions | R Programming language Interview Questions |
SAS DI Interview Questions | Advanced SAS Interview Questions |
Base Sas Interview Questions | SAS Macro Interview Questions |
Clinical Data Management Interview Questions |
SAS Programming Related Practice Tests |
|
---|---|
Logistics Practice Tests | Clinical SAS Practice Tests |
SAS DI Practice Tests |
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.