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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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