BookmarkSubscribeRSS Feed
Rsadiq1
Calcite | Level 5

Hi I am having an issue, My variables are numeric (according to SAS) and I want to convert them to character, to use the compress statement, but I'm getting this error and not sure if its my put statement that is wrong?

 

                                        76
MPRINT(STEP2):   create table ALL_NPART as select distinct a.* ,b.MP_FIRSTNAME as _Fname ,b.MP_LASTNAME as _Lname ,b.indv_id
,b.MP_MANAGEDPERSONID ,b.MP_BIRTHDATE as _DOB ,b.MP_zip as _zip from outlib.MCP_QUAL as a left join refdata.xwalk_careone_crm as b
on UPCASE(COMPRESS(put(a.PtFirst))) = UPCASE(COMPRESS(put(b.MP_FIRSTNAME))) and UPCASE(COMPRESS(put(a.PtLast))) =
UPCASE(COMPRESS(put(b.MP_LASTNAME))) ;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
              CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=. 

4 REPLIES 4
ChrisHemedinger
Community Manager

I think you're specifying the table alias wrong.  Instead of:

 

outlib.MCP_QUAL as a left join refdata.xwalk_careone_crm as b

 

Simply (no AS):

 

outlib.MCP_QUAL a left join refdata.xwalk_careone_crm b

 

I take that back.  AS is fine.  How about placing parens around the entire ON condition?

 

on (
UPCASE(COMPRESS(put(a.PtFirst))) = UPCASE(COMPRESS(put(b.MP_FIRSTNAME))) 
  and UPCASE(COMPRESS(put(a.PtLast))) = UPCASE(COMPRESS(put(b.MP_LASTNAME)))
);
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Rsadiq1
Calcite | Level 5

Sorry, let me clarify the problem the only reason I put the put function is because of this error, how do I make my variables a character expression?

 

 

MPRINT(STEP2):   create table ALL_NPART as select distinct a.* ,b.MP_FIRSTNAME as _Fname ,b.MP_LASTNAME as _Lname ,b.indv_id
,b.MP_MANAGEDPERSONID ,b.MP_BIRTHDATE as _DOB ,b.MP_zip as _zip from outlib.MCP_QUAL as a left join refdata.xwalk_careone_crm as b
on UPCASE(COMPRESS(strip(a.PtFirst))) = UPCASE(COMPRESS(strip(b.MP_FIRSTNAME))) and UPCASE(COMPRESS(strip(a.PtLast))) =
UPCASE(COMPRESS(strip(b.MP_LASTNAME))) ;
ERROR: Function STRIP requires a character expression as argument 1.
ERROR: Function STRIP requires a character expression as argument 1.

Astounding
PROC Star

PtFirst is numeric.  How could it ever match the value in MP_LASTNAME, no matter how many functions you apply to it?  Do you expect that MP_LASTNAME will sometimes contain a set of digits?  Do you possess a format that translates the numeric value of PtFirst into a set of characters?

TomKari
Onyx | Level 15

You aren't including a format with your "put" function. You'll get the same error with this:

 

proc sql;

select UPCASE(COMPRESS(put(a.age))) from sashelp.class a;

quit;

 

Tom

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 3521 views
  • 4 likes
  • 4 in conversation