I've the date variable as follows and it is in character. Based on this field I've to create the new field (KNDEIND) and it should be in character and the rule for the new field is PODVERD-1. Could you please help me understand how can I achieve this in one step?
PODVERD | KNDEIND |
2017-11-25 | 2017-11-24 |
If you would store dates as SAS intended, you could simply use:
KNDEIND = PODVERD - 1;
However, since the requirement is to use character dates, you need to jump through a couple of hoops:
KNDEIND = put(input(podverd, yymmdd10.) - 1, yymmddd10.);
I see that you have over 700 posts to the sas forums, and are labelled a "PROC STAR". I feel that I (and others) are the object of (let's say) a distinct lack of effort. Your question is not even accompanied by a report of your own efforts to solve the problem.
I 2nd @mkeintz response!
Since subtraction is generally not a character function, or at least folks don't have a universal standard of what it would mean, the obvious bit is turn it into a numeric, do the subtraction or data adjustment and then put the numeric to a character.
kndeind= put ( intnx('day',input(podverd,yymmdd10.),-1),yymmddd10.);
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.