Quite simply I'm trying to write a case statement that will let me know if date.B is 12 months older than date.A, then 'out of warranty'. I used to writing it in DB2 like this
SQL NOEXEC;
SELECT
(case when t1.'''Warranty End date''n'n is null then ''
when t1.'''Warranty End date''n'n>t1.'''Purchase date''n'n+ 12 months then 'In Warrenty At Time of Call'
else '' end) AS CALCULATION
How do write this code in Proc SQL ?
Hi,
Something like:
proc sql;
create table WANT as
select case when WARRANTY_END_DATE is null then ''
when WARRANTY_END_DATE > intnx('MONTHS',PURCHASE_DATE,12) then "In warranty"
else "" end as CALCULATION
from HAVE;
quit;
This assumes there is a dataset called HAVE with variables WARRANTY_END_DATE and PURCHASE_DATE, and that they are both already date format.
Hi,
Something like:
proc sql;
create table WANT as
select case when WARRANTY_END_DATE is null then ''
when WARRANTY_END_DATE > intnx('MONTHS',PURCHASE_DATE,12) then "In warranty"
else "" end as CALCULATION
from HAVE;
quit;
This assumes there is a dataset called HAVE with variables WARRANTY_END_DATE and PURCHASE_DATE, and that they are both already date format.
Thanks I see what I did wrong. It works.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.