I have a ringing situation, because I created a column with case when, but after run it shows that all fields are empty, but if I create a query with one of the conditions, it shows the results. The same in Excel, when it will generate a SAS file, it shows that there are empty fields, but when I created a pivot table, it shows me the results.
What could it be caused by ?
My code :
proc sql; create table kredyty as select *, case when (DEF_PREV_MONTH) = '0' and (spr_DEFAULT) = '1' then '1' when (DEF_PREV_MONTH) = '1' and (spr_DEFAULT) = '1' then '0' end as NEW_DEFAULT from kredyty as a left join (select spr_NRB, DEF_PREV_MONTH from NewDef) as b on a.spr_NRB = b.spr_NRB ; quit;
I note that you do not have any ELSE clause on your CASE statement.
This means that if spr_DEFAULT is anything other than '1', you will get a missing (blank) value, and if DEF_PREV_MONTH is not '1' or '0' you will also get a blank value.
That is probably what happens; but unless you can share some actual data (as datastep code, please), it is hard to say where things go wrong.
I note that you do not have any ELSE clause on your CASE statement.
This means that if spr_DEFAULT is anything other than '1', you will get a missing (blank) value, and if DEF_PREV_MONTH is not '1' or '0' you will also get a blank value.
That is probably what happens; but unless you can share some actual data (as datastep code, please), it is hard to say where things go wrong.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.