BookmarkSubscribeRSS Feed
Marilyn
Calcite | Level 5
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;
3 REPLIES 3
DanielSantos
Barite | Level 11
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
Marilyn
Calcite | Level 5
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;
Doc_Duke
Rhodochrosite | Level 12
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.).

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1482 views
  • 0 likes
  • 3 in conversation