Using the above screenshot of data, I am trying to determine the employees that are eligible for a 1% bonus.
The certifications are only valid for seven years. Any certification tests passed over seven years ago from today’s date are expired. I need to eliminate those employees that have expired certifications in either Base or Advanced tests. Then output the remaining employees’ names, certification dates, and their bonuses to the output window using appropriate date and dollar formats. I can tell that only 2 employees are eligible for the bonus (Morris and Stewart), but I have no idea as to how write the code to output the desired results.
Please help if you can!
data want;
set work.bonus;
/* Check for expired certifications */
if not (intck('year',basedate,today(),'C')<7 and
intck('year',advanceddate,today(),'C')<7) then delete;
bonus=salary*0.01;
run;
The logic in my original IF statement was incorrect. The above code fixes it.
UNTESTED CODE
data want;
set have;
/* Check for expired certification */
if not (intck('year',basedate,today(),'C')<7 or
intck('year',advanceddate,today(),'C')<7) then delete;
bonus=salary*0.01;
run;
Thank you PaigeMiller. After adding that to the code, it only deletes the base dates that are less than 7 years. It doesn't appear to do it for the advanced dates. Do you perhaps have any input as to why? Thanks!
If you could provide your data as a SAS data step, I (or someone) could actually provide code that has been tested.
@ Paige,
I hope this is what you mean. Please see below.
Obviously, you didn't test this code, because it doesn't read the data properly. And honestly, I have other things more important to me than getting your data to read properly. You get the data to read properly, and then I'm sure I will have a solution to the original problem.
As a new user of SAS, I'm trying to learn the best I can. I did test all code and interpreted the results based on my limited knowledge.
With that being said, there's absolutely no need for you to be nasty nor rude about having "more important" things to do. Perhaps if you don't have the time to provide proper guidance/answers, you should not reply to any requests for real help. Thanks you, next.
My apologies. I did not intend to be rude, but it came out that way. I would still like to help you get the results you want.
I'm not sure what you meant by not getting the data to read properly - not sure how I'd know that it didn't. I've done all I could do with providing sample data for you and don't know how to move forward in getting you additional information you say you need. So, I suppose I will keep trying to adjust my code to obtain the desired results. Thanks.
When I paste your code into the editor this is what I see:
data WORK.BONUS;. infile datalines dsd truncover;. input name:$8. salary:32. basedate:MMDDYY10. advanceddate:MMDDYY10. bonus:32.;. format basedate MMDDYY10. advanceddate MMDDYY10.;. datalines;. CAMPBELL 104600 12/01/2012 01/01/2008 1046. EDWARDS 72300 02/01/2013 06/01/2010 723. MORRIS 87200 02/04/2013 11/01/2012 872. ROGERS 70700 07/01/2012 10/01/2008 707. SANCHEZ 103300 09/01/2012 11/01/2009 1033. ;;;;
I might guess that some of this code went through some program other than the SAS edtor that attached a bunch of periods at the ends of the lines. They cause ERRORS.
After removing the unwanted periods and removing the DSD option, which was forcing some pad reading based on the formats on the input I get this
data WORKBONUS; infile datalines truncover; input name:$8. salary:32. basedate:MMDDYY10. advanceddate:MMDDYY10. bonus:32.; format basedate MMDDYY10. advanceddate MMDDYY10.; datalines; CAMPBELL 104600 12/01/2012 01/01/2008 1046 EDWARDS 72300 02/01/2013 06/01/2010 723 MORRIS 87200 02/04/2013 11/01/2012 872 ROGERS 70700 07/01/2012 10/01/2008 707 SANCHEZ 103300 09/01/2012 11/01/2009 1033 ;;;;
Which does run.
It does help on this forum to paste plain text, such as code or log entries into a code box opened with the {I} as the main message windows will reformat text and will allow odd characters that are not seen to sneak into the HTML.
Thank you for the reply @ballardw. I can't say that I know what to do with the information you provided (I'm really new to SAS and don't know all of the processes and terminologies, etc.), but I do thank you for taking the time to provide additional information.
data want;
set work.bonus;
/* Check for expired certifications */
if not (intck('year',basedate,today(),'C')<7 and
intck('year',advanceddate,today(),'C')<7) then delete;
bonus=salary*0.01;
run;
The logic in my original IF statement was incorrect. The above code fixes it.
Thank you very much.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.