BookmarkSubscribeRSS Feed
omega1983
Calcite | Level 5


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

2 REPLIES 2
DBailey
Lapis Lazuli | Level 10

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;

ghastly_kitten
Fluorite | Level 6

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

sas-innovate-2024.png

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.

 

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
  • 2 replies
  • 673 views
  • 0 likes
  • 3 in conversation