BookmarkSubscribeRSS Feed
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Hello all-
I have a Proc SQL that goes like this (truncated to the problem part.)

To explain-the format $Special gives either a 'BMT' or 'ONC' designation.
What I am attempting to do is make a case in that when it does not match those two parameters it goes to another table and grabs the designaton from there. I have tried difference variances such as call the format and then try to override when blank, but that doesn't seem to work either..
Any advice would be helpful.

Thank you.

Lawrence

proc sql;
create table L7 as Case when PUT(A.Attending_Physician, $Special.) ne ('BMT'||'ONC')
then C.Svce else PUT(A.Attending_Physician, $Special.) end as SVC
FROM ACUTE7L as A LEFT JOIN GOLDSBY as C on A.VISIT=C.VISIT;
QUIT;
3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12
I think that you have to do this with two queries.

The CASE statement is a mixture of SQL and DATA step logic (CASE clauses are OK, THEN and ELSE are not). Lastly, the PUT (..) NE ('BMT'||'ONC') won't work because you are both mixed syntax and are using a concatenation operator.

Create a table for the BMT and ONC folk and then one for the others. Finally combine the two using the UNION operator in SQL..
polingjw
Quartz | Level 8
In your query, the case expression needs to be part of a select clause. Try adding the word SELECT before the word CASE in your proc sql step. I don't understand what PUT(A.Attending_Physician, $Special.) ne ('BMT'||'ONC') is suppose to do. Based on your description, I think that you might want to use PUT(A.Attending_Physician, $Special.) not in ('BMT' 'ONC') .
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Thanks for the help, Polingjw's query worked best.
The PUT(A.Attending_Physician, $Special.) simply assigns a format that I created. Just my SQL could use some work.

Thank you.

Lawrence

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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