data s ;
length emp $ 10 boss $ 10 ;
input emp $ boss ;
cards ;
harish ashok
ashok siva
siva madhavarao
madhavarao ramaya
;
by using above dataset assign super boss like see below
emp boss superboss
harish ashok siva
ashok siva madhavarao
siva madhavarao ramaya
madhavarao ramaya
;
Do like this
data s ;
length emp $ 10 boss $ 10 ;
input emp $ boss ;
cards ;
harish ashok
ashok siva
siva madhavarao
madhavarao ramaya
;
data want;
merge s s(firstobs=2 rename=(boss=superboss) keep=boss);
run;
data s ;
length emp $ 10 boss $ 10 ;
input emp $ boss ;
cards ;
harish ashok
ashok siva
siva madhavarao
madhavarao ramaya
;
proc sql ;
create table want as
select a.* ,b.boss as super_boss
from s as a left join s as b
on a. boss=b.emp;
quit;
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.