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

I'm trying to create the numeric variable called PODVER using the following case when in DI Studio. But I'm not sure why I'm getting missing values in PODVER. NEW_RENEWAL_DAY_MONTH_YEAR and CURRENT_DATE are numeric variables and it has values like 20SEP and 20SEP2018 respectively. Please be informed that I'm applying the format DATE9. in the new variable PODVER.

 

case when NEW_RENEWAL_DAY_MONTH_YEAR=REPORTING_DATE_ddmon  and KNKATD='7'  then REPORTING_DATE_ddmonyyyy 
         when input(cats(NEW_RENEWAL_DAY_MONTH_YEAR,"2018"),date9.) >CURRENT_DATE then input(cats(NEW_RENEWAL_DAY_MONTH_YEAR,"2018"),date9.) 
         else input(cats(NEW_RENEWAL_DAY_MONTH_YEAR,"2019"),date9.)
end

Please guide me to resolve the issue.

 

1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

If your date variables are numeric, then the input(cats(...)) construct won't work as intended. You are not getting any error messages because CATS automatically translates numeric to character, but it does so using the BEST32. format.

 

What you want to do is probably something like this:

case when NEW_RENEWAL_DAY_MONTH_YEAR=REPORTING_DATE_ddmon  and KNKATD='7'  then REPORTING_DATE_ddmonyyyy 
         when mdy(month(NEW_RENEWAL_DAY_MONTH_YEAR),day(NEW_RENEWAL_DAY_MONTH_YEAR),2018) >CURRENT_DATE then mdy(month(NEW_RENEWAL_DAY_MONTH_YEAR),day(NEW_RENEWAL_DAY_MONTH_YEAR),2018)
         else mdy(month(NEW_RENEWAL_DAY_MONTH_YEAR),day(NEW_RENEWAL_DAY_MONTH_YEAR),2019)
end

View solution in original post

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

Please refer to the guidance on posting a question and review what you post.  There are several posts on this topic now.  You state that:

"NEW_RENEWAL_DAY_MONTH_YEAR and CURRENT_DATE are numeric variables and it has values like 20SEP and 20SEP2018"

A numeric variable cannot contain a text string: "20SEP", in fact a numeric variable (date) also cannot contain 20SEP, although a full numeric date can be formatted to display on day and month.

Please start by providing us with some text data which accurately shows what your data is and how it looks, particulalrly in a datastep so that we can clearly see formats, types etc.     

Unfortunately I cannot debug anything from what you have posted as it all contradicts each other, this for instance:

NEW_RENEWAL_DAY_MONTH_YEAR=REPORTING_DATE_ddmon 

 How can a day/month/year variable ever be equal to a ddmon variable, and how can a ddmon variable be a date - which can only be all parts-ddmon and yyyy.

 

Start with test data in the form of a datastep - data which matches what you have for all variables in question.

s_lassen
Meteorite | Level 14

If your date variables are numeric, then the input(cats(...)) construct won't work as intended. You are not getting any error messages because CATS automatically translates numeric to character, but it does so using the BEST32. format.

 

What you want to do is probably something like this:

case when NEW_RENEWAL_DAY_MONTH_YEAR=REPORTING_DATE_ddmon  and KNKATD='7'  then REPORTING_DATE_ddmonyyyy 
         when mdy(month(NEW_RENEWAL_DAY_MONTH_YEAR),day(NEW_RENEWAL_DAY_MONTH_YEAR),2018) >CURRENT_DATE then mdy(month(NEW_RENEWAL_DAY_MONTH_YEAR),day(NEW_RENEWAL_DAY_MONTH_YEAR),2018)
         else mdy(month(NEW_RENEWAL_DAY_MONTH_YEAR),day(NEW_RENEWAL_DAY_MONTH_YEAR),2019)
end

sas-innovate-white.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.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 779 views
  • 0 likes
  • 3 in conversation