BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chrissowden
Obsidian | Level 7

Job_codeJob_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;

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
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.

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20
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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 625 views
  • 0 likes
  • 2 in conversation