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.).

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1378 views
  • 0 likes
  • 3 in conversation