I received a request from a customer to develop a report using multiple tables with multiple scenarios. My thought was to combine all of the "and" and then the "or" groups. The report should show data if the following conditions are present Here is the example:
((if elapse_days <=15 and if Ins_Code in ('A','B') or if Ins_Code EQ spaces) AND IF Assoc_ID not like Z AND ((IF Prop_Type NE 2 OR If Prop_Type EQ 2 and Disburement NE 250))
Here is what I am doing so far;
%let elapse = TODAY()-Set_Date;
data INS1(keep=ID Ins_Code Elapse_Time);
set File1;
where Ins_Code in ('A','B','');
Elapse_Time=&Elapse;
run;
This is where I stopped. I need to address the following:
Assoc_ID(from a table called File2),
Prop_Type(from File3) and
Disbursement(form File4)
The part I have bolded is where I get stuck. At some point in time I need to merge the 4 tables based on the ID
just to get you started. I'm not sure if you need inner or outer joins based on your requirements.
proc sql;
create table want as
select
t1.*
,t2.assoc_id
,t3.prop_type
,t4.disbursement
from
file1 t1
inner join file2 t2
on t1.id=t2.id
inner join file3 t3
on t1.id=t3.id
inner join file4 t4
on t1.id=t4.id
where
(date() - t1.set_date) <=15
and t2.assoc_id not like 'Z%'
and t3.prop_type ne 2
and (t3.prop_type=2 and t4.disbursement ne 250)
;
quit;
Could you please tell us some more information about your task?
DO you need a hint about how to join 4 tables (which provided by DBeily), or you need a way to do it based on a certain conditions?
p.s.
By the way
((IF Prop_Type NE 2 OR If Prop_Type EQ 2 and Disburement NE 250)) == ((IF Prop_Type NE 2 OR Disburement NE 250))
since (not x) or x and y == (not x) or y
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.