I have a sql procedure with about 5 "case whens" (case when _ then _ else _ end as _ ). I'm trying to figure out how I can take a variable created in the "end as _ " portion of the previous case statement and use it in the "case when _ " portion of the next case statement within the same proc sql. Here's my code: case when a.type = 'Non-Agency' then 'Non-Agency' when a.Cat = 'Municipal' then 'Municipal' else 'Agency' end as Shock, case when Shock = 'Non-Agency' and a.Cat = l.breakdown then l.Cat else 'None' end as Lookup, So above, the first case statement creates the variable Shock. I want to reference Shock in the next case statement. But the log says "ERROR: The following columns were not found in the contributing tables: Shock." Besides starting a 2nd proc sql, how can I get around this?
... View more