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)))
);
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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