I would like to create a list of IDs (bee_created) that combine a treatment group (i), replicate (j) and serial number (k). I have 9 replicates to work on, each with slight variations in serial numbers in the treatment groups. So it would a lot more efficient to create all the IDs in macro do loops. I've browsed some articles and I suppose that %scan may be used but I haven't been able to produce working codes.
For each replicate, there are five treatment groups 'aa','ab', 'ac', 'ea' and 'ec'. I am needing a macro that could replace the following 4 data sets. Note the only differences are in the values of i, j and k; else are copy-and-paste. Thanks in advance
/*dataset 1*/
data tag_num_replicate01_02;
length i $5. bee_created $9.;
exp_name="&exp_name";
do i= 'aa','ab', 'ac', 'ea','ec';
do j='01','02';
do k=101 to 210;
bee_created=compress (i||j||'-'||put(k, best.));
rename i=group_id;
output;
end;
end;
end;
run;
/*dataset 2*/
data tag_num_replicate04a;
length i $5. bee_created $9.;
exp_name="&exp_name";
do i= 'aa','ab', 'ac';
do j='04';
do k=501 to 615;
bee_created=compress (i||j||'-'||put(k, best.));
rename i=group_id;
output;
end;
end;
end;
run;
/*dataset 3*/
data tag_num_replicate04b;
length i $5. bee_created $9.;
exp_name="&exp_name";
do i= 'ea';
do j='04';
do k=501 to 623;
bee_created=compress (i||j||'-'||put(k, best.));
rename i=group_id;
output;
end;
end;
end;
run;
/*dataset 4*/
data tag_num_replicate04c;
length i $5. bee_created $9.;
exp_name="&exp_name";
do i= 'ec';
do j='04';
do k=501 to 620;
bee_created=compress (i||j||'-'||put(k, best.));
rename i=group_id;
output;
end;
end;
end;
run;
I tried to generate a list of 'aa', 'ab' and 'ac' but ended up creating four variables i, aa, ab and ac. I would highly appreciate if you could also show me what is wrong in the following codes.
/*macro not working*/
%macro tag_generate(groups=);
data tag_num_test;
exp_name="&exp_name";
%do i= 1 %to 3;
j=%scan(&groups, &i);
output;
%end;
run;
%mend tag_generate;
%tag_generate(groups= aa ab ac);
Chang