DATA Step, Macro, Functions and more

numeric/char conflict

Reply
Contributor
Posts: 20

numeric/char conflict

How can I get this where statement in proc sql to work when one ssn is a char and the other is numberic?

where B.pat_ssn = A.SSN;
Super Contributor
Posts: 474

Re: numeric/char conflict

You'll have to convert one of them.

to convert from num to char, use the put function.
see: http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000199354.htm

to convert from char to num, use the input function.
see: http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000180357.htm

Greetings from Portugal.

Daniel Santos at www.cgd.pt
Contributor
Posts: 20

Re: numeric/char conflict

Posted in reply to DanielSantos
ok...at what point in the procedure do I do this?
proc sql;
CREATE TABLE x.out04 AS SELECT B.kssn FORMAT=$9. AS kSSN,
A.ISSN FORMAT=$9.,
A.DIAG1 FORMAT=$7.
FROM N.YR2004 AS A ,
x.ketssn AS B
where B.kssn = A.ISSN;
QUIT;
Trusted Advisor
Posts: 2,116

Re: numeric/char conflict

In the WHERE clause, e.g.

WHERE b.pat_ssn = put(a.ssn,9.)

If b.pat_ssn has embedded hyphens, you'll need to use the SSN format for a.ssn (say ssn11.).
Ask a Question
Discussion stats
  • 3 replies
  • 176 views
  • 0 likes
  • 3 in conversation