BookmarkSubscribeRSS Feed
KirLiSakaL
Calcite | Level 5

hi everyone,

 

PROC SQL NOEXEC;
   SELECT (MAX(CASE WHEN(d1= 'C' AND d2= 'X') 
         THEN sutun1||' '||sutun2 ELSE ' ' END)) AS CALCULATION
      FROM BB2.Ott t1;
QUIT;

 

ERROR: Concatenation (||) requires character operands.

 

what's my fault?

thaks 🙂

2 REPLIES 2
Reeza
Super User

Exactly what it says, your variables should be character but they're numeric. 

 

You can use CATX instead, but it converts numbers using the BEST format so verify it gives you what you want.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is it your actually trying to do as there are various issues with your code.  First, you have the problem as given by @Reeza, you are concatenating (a string function) numeric variables.  Secondly, you are max()ing (a numeric function) on character data.  

Provide a small bit of test data and show what you want out, maybe something like:

proc sql noexec;
  select  max(coalesce(SUTUN1,SUTUN2)) as CALCULATION
  from    (select * from BB2.OTT where D1="C" and D2="X");
quit;

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
  • 2 replies
  • 9861 views
  • 1 like
  • 3 in conversation