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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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