To simplify the whole program
ods output onewayfreqs=work.owf(rename=(frequency=count));
proc freq data=sashelp.CLASS ;
tables _all_/nocum nopercent ;
run;
data work.owf2;
length v_name v_value $ 200;
set work.owf;
v_name=scan(table,2);
v_value=scan(catx(' ',of sex name--weight ),1,' ');
*name is the first variable,weight is the last variable in sashelp.class table;
keep v_name v_value count;
run;
May I ask what is the reason why you are complicating things by creating new sexes '(a1) F' and '(a2) M' ? I have never heard of these, I'm sure most people don't know what these cryptic codes a1 and a2 mean, so I have left these out of the solution. If you really need them, put them back into my code.
Another simplification would be not to rename FREQUENCY to COUNT, I don't see the point of taking the time to do that either, but you don't need a DATA step to do that rename.
... View more