SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
air_dedman
Calcite | Level 5

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

air_dedman
Calcite | Level 5

Thanks I see what I did wrong. It works.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1242 views
  • 0 likes
  • 2 in conversation