For every parameter, there is needed different scope of subcategories. I'm trying to do these by getting the respective array name for the respective parameter's name in the macro loop, but I can't find the way to get the array name in the loop.
%macro arrs(j);
%do i=1 %to %dim(arr.&j);
category=arr1(i);
output;
%end;
%mend arrs;
data mock;
length param category $200;
array arr1(4) $200 ("Safety Analysis Set [a]" "Safety Run-in Set [b]" "Efficacy Evaluable Set (c)" "Immunogenity Analysis Set (d)");
array arr2(2) $200 ("Completed Study" "Discontinued Study");
array arr3(2) $200 ("Competed Treatment" "Terminated Treatment");
array arr4(6) $200 ("Death" "Lost to Follow-up" "Withdrawal by patient from study" "Termination of study by sponsor"
"Completed 24 months of therapy" "Other");
do id=1 to 6;
param=put(id,param.);
%arrs(id);
output;
end;
run;
What is this %DIM() macro your code is trying to call?
Perhaps you just meant to write:
%macro arrs(j);
do i=1 to dim(arr&j);
category=arr&j(i);
output;
end;
%mend arrs;
Or perhaps you wanted to do:
%macro arrs;
%local j;
%do j=1 %to 4;
param=put(&j,param.);
do i=1 to dim(arr&j);
category=arr&j(i);
output;
end;
%end;
%mend arrs;
data mock;
length param category $200;
array arr1(4) $200 ("Safety Analysis Set [a]" "Safety Run-in Set [b]" "Efficacy Evaluable Set (c)" "Immunogenity Analysis Set (d)");
array arr2(2) $200 ("Completed Study" "Discontinued Study");
array arr3(2) $200 ("Competed Treatment" "Terminated Treatment");
array arr4(6) $200 ("Death" "Lost to Follow-up" "Withdrawal by patient from study" "Termination of study by sponsor"
"Completed 24 months of therapy" "Other");
%arrs;
run;
What is this %DIM() macro your code is trying to call?
Perhaps you just meant to write:
%macro arrs(j);
do i=1 to dim(arr&j);
category=arr&j(i);
output;
end;
%mend arrs;
Or perhaps you wanted to do:
%macro arrs;
%local j;
%do j=1 %to 4;
param=put(&j,param.);
do i=1 to dim(arr&j);
category=arr&j(i);
output;
end;
%end;
%mend arrs;
data mock;
length param category $200;
array arr1(4) $200 ("Safety Analysis Set [a]" "Safety Run-in Set [b]" "Efficacy Evaluable Set (c)" "Immunogenity Analysis Set (d)");
array arr2(2) $200 ("Completed Study" "Discontinued Study");
array arr3(2) $200 ("Competed Treatment" "Terminated Treatment");
array arr4(6) $200 ("Death" "Lost to Follow-up" "Withdrawal by patient from study" "Termination of study by sponsor"
"Completed 24 months of therapy" "Other");
%arrs;
run;
For this problem it is probably easier to forget the arrays and the macro.
data mock;
length param category $200;
param=put(1,param.);
do category=
"Safety Analysis Set [a]","Safety Run-in Set [b]","Efficacy Evaluable Set (c)","Immunogenity Analysis Set (d)";
output;
end;
param=put(2,param.);
do category="Completed Study","Discontinued Study";
output;
end;
...
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.