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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.