Desktop productivity for business analysts and programmers

SAS variable conversion error

Reply
Occasional Contributor
Posts: 19

SAS variable conversion error

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, ^, ^=, |, ||, ~, ~=. 

Community Manager
Posts: 2,954

Re: SAS variable conversion error

[ Edited ]

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)))
);
Occasional Contributor
Posts: 19

Re: SAS variable conversion error

Posted in reply to ChrisHemedinger

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.

Super User
Posts: 5,505

Re: SAS variable conversion error

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?

PROC Star
Posts: 1,167

Re: SAS variable conversion error

Posted in reply to Astounding

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

Ask a Question
Discussion stats
  • 4 replies
  • 515 views
  • 4 likes
  • 4 in conversation