BookmarkSubscribeRSS Feed
Geo-
Quartz | Level 8

SAS sql into sas data step

proc sql noprint;
create table tableC as
slect A.a,A.b,A.c,B.d,B.e
from tableA A
inner join tableB B
on A.b=B.b;

delete from tableC
where not (substr(d,1,1)='1' and length(trim(d))=11)
or d is null;

delete from tableC
where d in
(select d from tableC group by d having count(1)>1);
quit;

thank you for your time!

1 REPLY 1
Jagadishkatam
Amethyst | Level 16
proc sort data=tablea;
by b;
run;

proc sort data=tablea;
by b;
run;


data tablec;
merge tablea(in=ina) tableb(in=inb);
by b;
if ina;
if not (substr(d,1,1)='1' and length(trim(d))=11);
dc=(substr(d,1,1);
run;

proc sort data=tablec;
by dc;
run;

data tablec(where=(dc <=1));
do until(last.dc);
set tablec;
by dc;
retain count;
if first.dc then count=1;
else count+1;
end;
do until(last.dc);
set tablec;
by dc;
output;
end;
run;

N.B. Untested code.

Thanks,
Jag

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 906 views
  • 0 likes
  • 2 in conversation