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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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