Help using Base SAS procedures

Looking for Starting Point Using SAS Code pulling from Multiple Tables

Reply
Contributor
Posts: 59

Looking for Starting Point Using SAS Code pulling from Multiple Tables


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

Super Contributor
Posts: 578

Re: Looking for Starting Point Using SAS Code pulling from Multiple Tables

Posted in reply to omega1983

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;

Contributor
Posts: 41

Re: Looking for Starting Point Using SAS Code pulling from Multiple Tables

Posted in reply to omega1983

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

Ask a Question
Discussion stats
  • 2 replies
  • 180 views
  • 0 likes
  • 3 in conversation