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

Hi Guys,

I'm using SAS Enterprise Guide 5.1 I'm using the GUI to prepare the report.

I'm transferring my reports from SQL/Excel solutions to SAS.

So here is the SQL that I used:

MAX(CASE

                  WHEN Cc.ContactTypeID = 5

                  THEN Cc.ContactValue

                  ELSE Null END) AS 'Email'

The data basically looks like this:

Cc.Custcode              Cc.ContactTypeID          Cc.ContactValue         

112233                       1                                   0422778899              

112233                       2                                   0395874521    

112233                       5                                   email@email.com

112244                       5                                   another@email.com

What I'm trying to do is this:

Cc.CustCode               Mobile                    Phone                 Email    

112233                        0422778899           0395874521         email@email.com

112244                                                                               another@email.com

Here is what I have for the email field:

MAX(CASE WHEN CustomerContact.ContactTypeID = 5

THEN CustomerContact.ContactValue

ELSE .

END)

I'm getting the following error:

ERROR: Result of WHEN clause 2 is not the same data type as the preceding results.

I've tried to read up on a solution of this- and I've read the issue could have something to do with filters.

I have one filter on (and it's the same filter that I had in the WHERE Clause in my report- limiting to orders which were delivered- so it's unrelated. Removing it makes no difference).

I'm getting to a point where I'm stuck and I couldn't find anything on the SAS forums which solved it for me.

Does anyone have any idea?

Bree

1 ACCEPTED SOLUTION

Accepted Solutions
breelloyd
Fluorite | Level 6

Actually- looks like doing this solved it:

MAX(CASE WHEN CustomerContact.ContactTypeID = 5

THEN CustomerContact.ContactValue

ELSE ""

END)

does anyone understand why?

View solution in original post

3 REPLIES 3
breelloyd
Fluorite | Level 6

Actually- looks like doing this solved it:

MAX(CASE WHEN CustomerContact.ContactTypeID = 5

THEN CustomerContact.ContactValue

ELSE ""

END)

does anyone understand why?

Tom
Super User Tom
Super User

Because " " is a character value like he variable CONTACTVALUE is and . (missing) is a numeric value.  That is what the error message was telling you. 

ERROR: Result of WHEN clause 2 is not the same data type as the preceding results.
breelloyd
Fluorite | Level 6

That makes sense.

I'm not used to not having a null

Thanks for that though- I like to understand why I'm getting errors, even if I solve it. It'll help me later on if it comes up again.

Thanks for taking the time to respond.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 4568 views
  • 3 likes
  • 2 in conversation