Here is a solution building upon your line of thought. I used a macro to cycle through the two analysis variables, however, the non-macro code is in the comments below it data have;
input category $1-6 group $8-16 frequency 18 percent 20-24;
cards;
female treatment 3 33.33
male treatment 6 66.67
female placebo 1 33.33
male placebo 2 66.67
;
run;
proc sort; by category; run;
%let vars=%str(frequency percent) ;
%macro trans;
%local i _var;
%do i=1 %to %sysfunc(countw(&vars));
%let var = %scan(&vars, &i);
proc transpose data=have out=&var (drop=_name_) suffix=_&var;
by category ;
id group;
var &var;
run;
%end;
data want;
merge &vars;
by category;
run;
proc print;
id category;
run;
%mend;
%trans;
/*
proc transpose data=have out=frequency (drop=_name_) suffix=_frequency;
by category ;
id group;
var frequency;
run;
proc transpose data=have out=percent(drop=_name_) suffix=_percent;
by category ;
id group;
var percent;
run;
data want;
merge frequency percent;
by category;
run;
*/
... View more