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!
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.
Ready to level-up your skills? Choose your own adventure.