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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 322 views
  • 1 like
  • 2 in conversation