Guest_imported
New member
- Jan 1, 1970
- 0
I am working with 2 tables with telecommunication data. One table has telephone numbers that have been disconnected and the other has telephone numbers and repair information. The data appears like this.
Table Disconnects
TN ordcmpdt orddiscdt
6025551212 2002-01-01 2002-02-01
3035551212 2002-01-20 2002-02-21
Table Repair
TN RPRNUM numdisp compdt
6025551212 pr123456 2 2002-01-25
6025551212 pr234567 1 2002-01-27
6025551212 pr567890 1 2002-01-30
3035551211 ce545454 1 2002-01-22
3035551211 ce232322 2 2002-02-19
What I need is to do a left join with the disconnect table by TN and get a count of repair tickets (RPRNUM) and sum of number of dispatches (NUMDISP)
I used the following PROC SQL
Proc SQL;
create table discrpr as
select d.tn, count(r.rprnum) as tktcnt, sum(r.numdisp)as dispcnt from disconnect d, (select rprnum, numdisp from repair
where tn=d.tn group by d.tn, count(r.rprnum) as tktcnt,
sum(r.numdisp) as dispcnt) r
What I get is an error message
Can anyone help me merge these tables on tn and get the count and sum and also where the repair ticket is between the ordcmpdt and orddiscdt. I have not even attempted the last part!
Table Disconnects
TN ordcmpdt orddiscdt
6025551212 2002-01-01 2002-02-01
3035551212 2002-01-20 2002-02-21
Table Repair
TN RPRNUM numdisp compdt
6025551212 pr123456 2 2002-01-25
6025551212 pr234567 1 2002-01-27
6025551212 pr567890 1 2002-01-30
3035551211 ce545454 1 2002-01-22
3035551211 ce232322 2 2002-02-19
What I need is to do a left join with the disconnect table by TN and get a count of repair tickets (RPRNUM) and sum of number of dispatches (NUMDISP)
I used the following PROC SQL
Proc SQL;
create table discrpr as
select d.tn, count(r.rprnum) as tktcnt, sum(r.numdisp)as dispcnt from disconnect d, (select rprnum, numdisp from repair
where tn=d.tn group by d.tn, count(r.rprnum) as tktcnt,
sum(r.numdisp) as dispcnt) r
What I get is an error message
Can anyone help me merge these tables on tn and get the count and sum and also where the repair ticket is between the ordcmpdt and orddiscdt. I have not even attempted the last part!