Experts:
Another beginner question. How do you use the values in different observations as arguments for a function? I'm trying to concatenate string values from multiple observations. I'll use the sasuser.pilots as an example. Each observation has a person's name etc. What if you need to generate name lists so you can assign these people to teams of five?
Here's very clumsy code I managed to come up with. I'm sure it is not the way to go because if the dataset has hundreds of people, I would be in real misery :). Maybe my trouble is also not knowing how to use a do loop here.
Thank you for your time in advance.
data work.NameList;
set sasuser.pilots(keep=lastname)End=last ;
Length GroupList $ 500;
retain GroupList;
if _n_ < 11 then do;
Counter+1;
Grouplist=Catx(';',Grouplist,LastName);
if _n_=10 then do;
output;
GroupList='';
Counter=0;
end;
end;
if 11 <=_n_<=15 then do;
Counter+1;
Grouplist=Catx(';',Grouplist,LastName);
if _n_=15 then do;
output;
GroupList='';
Counter=0;
end;
end;
if _n_>15 then do;
Counter+1;
Grouplist=Catx(';',Grouplist,LastName);
if last=1 then output;
end;
run;
proc print data=work.namelist;
run;
... View more