Desktop productivity for business analysts and programmers

numeric to character

Reply
Occasional Contributor
Posts: 19

numeric to character

 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: 10,516

Re: numeric to character

Which variable(s)?

From the error message at least 2 of

a.PtFirst

b.MP_FIRSTNAME

a.PtLast

b.MP_LASTNAME

 

are numeric. Which ones? And from the comparison your result would be comparing a text version of a numeric to a name of some sort which very few of could be written as a numeric.

 

You apparently are continuing a discussion from another thread, without reference, because there is no "PUT" in you example to see where you may have been attempting to use it.

 

SHOW some data.

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

Super User
Super User
Posts: 6,502

Re: numeric to character

[ Edited ]

Macro generation will destroy any formatting you might have added to your code to make it readable. So let's retype the statement from your posted log and see if that makes it easier to understand what is happening.

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  a 
  left join refdata.xwalk_careone_crm  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))) 
;

So now that we can read the code it looks your problem is that your code expects that PTFIRST, PTLAST, MP_FIRSTNAME and MP_LASTNAME are character variables, which seems reasonable given their names, but unfortunately at least one of them is a number.

 

So you need to take a step back in your program's logic flow and figure out how you ended up making a variable like MP_LASTNAME as a number instead of string.

 

My bet is on using something like PROC IMPORT to guess at what types of variables to create.

Ask a Question
Discussion stats
  • 2 replies
  • 109 views
  • 0 likes
  • 3 in conversation