09-05-2014 05:55 AM
I have a variable 'Remaining months' but I want this in a year format within proc sql but unsure on how to do this, any ideas please?
Remaining months 60
I want to display 5 years
09-05-2014 06:10 AM
Simply divide by 12.
create table WANT as
strip(put(REMAINING_MONTHS / 12,best.))||" years" as YEARS
09-05-2014 06:28 AM
With the round function? Alternatively the floor (probably the best one for your scenario) or ceil functions depending on scenario.
To add, any SAS function can be used in a proc sql as long as you are not using pass-through (i.e. sending the sql to a database) as the DB wouldn't know about the SAS functions). In general though there are several of the functions which are present in both SAS and native SQL, round being one of them, though slightly different syntax.
09-05-2014 07:09 AM
Using a 5.2 format for years instead of best. - The best in this case is not your best. The best is showing as much as possible could make sense.
09-05-2014 01:56 PM
CREATE TABLE WANT AS
SELECT REMAINING_MONTHS,CATS((REMAINING_MONTHS / 12), "YEARS") AS YEARS FROM HAVE;