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