Job_code
in the variable job code there are levels " example TM1" is level 1...etc. Its a mixed variable and I want to separate the numeric value from the characters. If it doesn't have any numeric then leave it as is "example SPC" . I am trying to calculate a bonus variable using the numeric value from job_code.
Finally, produce a new variable for the year-end bonus, which is defined as:
3% for level 1 employees, plus $1,500 for all with 30 or more years of service
3.75% for level 2, plus $2,500 for all with 30 or more years of service
4.5% for level 3, plus $3,000 for all with 30 or more years of service
3.5% for others, plus $2,000 for all with 30 or more years of service
proc datasets lib=work kill;run;
filename rawdata '\\seashare\blumj\SAS Programming Data\Raw Data';
data pay;
infile rawdata('payroll.txt');
input @1 DOB date9. @10 Hire_date date9. Empid$ 19-22 gender$ 23 job_code$ 24-26 salary:comma.;
Today=today();
days = today - dob;
age = floor(days / 365);
work_days=today-hire_date;
Yrs_at_job=floor(work_days/365);
if age ge 62 then Retirement='Y';
else if age ge 55 and Yrs_at_job ge 25 then Retirement='Y';
else Retirement='N';
format Today date9. DOB date9. Hire_date date9. ;
drop days today work_days ;
run;
data test;
input job_code$ @@;
level=ifc(anydigit(job_code)=0, job_code, compress(job_code,, 'kd'));
datalines;
TA2 SPC
run;
As for your second requirement, use a Select-When Statement or a costum format.
data test;
input job_code$ @@;
level=ifc(anydigit(job_code)=0, job_code, compress(job_code,, 'kd'));
datalines;
TA2 SPC
run;
As for your second requirement, use a Select-When Statement or a costum format.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: