Hi Everybody,
I have a problem with SQL PROC DELETE query...
After I successfully created table Denlab I need to eliminate partly duplicated records in order to leave just those ones with the same ID who are the most recent
However those ones who have just one record shold not be touched. Those ones whose date are the same should not be touched either
Being new in SAS,I am trying to implement it as if I do it in Access but it looks like SAS does not accept alliaces in my DELETE query.
Also, since the required field criteria has a prefix bb.... I am totally confused as it looks like my SQL is in conflict with SAS syntax.
How should I implement my DELETE query in SAS?
Could you please give me a hand?
Thank You in advance,
Rina
*****************************************************************************************
libname d 'c:\MyFolder\SAS Datasets';
proc sql;
create table d.DenLab as
select bb.id,mc.id, bb.dt_day,ll.value_start,bb.rslt
FROM d.combineBothTbls mc
join D.Lab bb
on mc.id = bb.id
join D.mycct ll
on ll.Value_Start = bb.RSLT
WHERE DATEPART(bb.dt_day) GE '01Jan2004'd
AND DATEPART(bb.dt_day) LE '31Dec2004'd;
run; /*this is done succesfully*/
/* need to delete just those ones whith the same id who is the most recent under bb.dt_day*/
proc sql;
DELETE *
FROM DenLab a, DenLab b
WHERE a.[bb.dt_day] Is Not Null AND Int([bb.dt_day])<(SELECT Max(Int([bb.dt_day])) FROM b WHERE b.[id]=a.[id]);
run;
I have a problem with SQL PROC DELETE query...
After I successfully created table Denlab I need to eliminate partly duplicated records in order to leave just those ones with the same ID who are the most recent
However those ones who have just one record shold not be touched. Those ones whose date are the same should not be touched either
Being new in SAS,I am trying to implement it as if I do it in Access but it looks like SAS does not accept alliaces in my DELETE query.
Also, since the required field criteria has a prefix bb.... I am totally confused as it looks like my SQL is in conflict with SAS syntax.
How should I implement my DELETE query in SAS?
Could you please give me a hand?
Thank You in advance,
Rina
*****************************************************************************************
libname d 'c:\MyFolder\SAS Datasets';
proc sql;
create table d.DenLab as
select bb.id,mc.id, bb.dt_day,ll.value_start,bb.rslt
FROM d.combineBothTbls mc
join D.Lab bb
on mc.id = bb.id
join D.mycct ll
on ll.Value_Start = bb.RSLT
WHERE DATEPART(bb.dt_day) GE '01Jan2004'd
AND DATEPART(bb.dt_day) LE '31Dec2004'd;
run; /*this is done succesfully*/
/* need to delete just those ones whith the same id who is the most recent under bb.dt_day*/
proc sql;
DELETE *
FROM DenLab a, DenLab b
WHERE a.[bb.dt_day] Is Not Null AND Int([bb.dt_day])<(SELECT Max(Int([bb.dt_day])) FROM b WHERE b.[id]=a.[id]);
run;