BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
maliksmom2000
Obsidian | Level 7

I have two columns.  One has a code for inspections, the second has the dates of the inspections.  If the code is CM then I want it to return the date, if not I want it to be blank.

 

 I don't know what to put in the "XXX" below so it returns a blank.  I know it's not "" as it is a numeric expression and I know not to put a 0 or 1.  I'm sorry I can't seem to get this one down.

 

ifn(t1.MSAI_STAT_CD="CM", t1.MSAI_STAT_DT, XXX)

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

A period is the symbol for numeric missing values, no quotes. 

 

In SQL it’s more conventional to use CASE statements instead of IFN. For one, if you or someone ever needs to migrate this to a different SQL implementation this makes it much easier. 

 


@maliksmom2000 wrote:

I have two columns.  One has a code for inspections, the second has the dates of the inspections.  If the code is CM then I want it to return the date, if not I want it to be blank.

 

 I don't know what to put in the "XXX" below so it returns a blank.  I know it's not "" as it is a numeric expression and I know not to put a 0 or 1.  I'm sorry I can't seem to get this one down.

 

ifn(t1.MSAI_STAT_CD="CM", t1.MSAI_STAT_DT, XXX)


 

View solution in original post

1 REPLY 1
Reeza
Super User

A period is the symbol for numeric missing values, no quotes. 

 

In SQL it’s more conventional to use CASE statements instead of IFN. For one, if you or someone ever needs to migrate this to a different SQL implementation this makes it much easier. 

 


@maliksmom2000 wrote:

I have two columns.  One has a code for inspections, the second has the dates of the inspections.  If the code is CM then I want it to return the date, if not I want it to be blank.

 

 I don't know what to put in the "XXX" below so it returns a blank.  I know it's not "" as it is a numeric expression and I know not to put a 0 or 1.  I'm sorry I can't seem to get this one down.

 

ifn(t1.MSAI_STAT_CD="CM", t1.MSAI_STAT_DT, XXX)


 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 1 reply
  • 729 views
  • 0 likes
  • 2 in conversation