Hi All,
I have longitudnal data and grp variable and fl variable, values of grp as 1 2 3 4 5 6... and values for fl as 1 2 3... need to create variable net.
Is there any dynamic way to get the grp and fl values
if grp=1 then do; if fl=1 then net=1; if fl=2 then net=2;end;
if grp=2 then do; if fl=1 then net=3; if fl=2 then net=4;end;
if grp=3 then do; if fl=1 then net=5; if fl=2 then net=6;end;
if grp=4 then do; if fl=1 then net=7; if fl=2 then net=8;end;
my try :
%let maxgrp=4;%let fl=2;
proc sql;
select *,
%do i=1 %to &maxgrp; j=1 %to &fl;
case when grp=&i and fl eq &j then &i*&j;
end as trt
from ids;
quit;
Thanks
Sam
Thank you Reeza!!!
can we adopt this formula under the sql? if i used in data step i got the output , but if i want to adopt for sql, getting warning on log,
"net variable already exit in XXXX dataset"
Thanks
Sam
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.