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

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 ?

Gieorgie_0-1643617848036.png

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;
1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

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.

View solution in original post

2 REPLIES 2
s_lassen
Meteorite | Level 14

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.

Gieorgie
Quartz | Level 8
It is as you say, thanks for the advice;)

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 716 views
  • 1 like
  • 2 in conversation