BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gtran
Calcite | Level 5

Hello,

I try to multiply frequencies with a constant number but don't know how to do it. I use proc freq as follows:

proc freq data=abc;

table var1*var2/out=xyz;

run;

I want to multiply frequencies in the dummy table with a number to obtain adjusted frequencies. Anyone can tell me how to do it? if proc freq does not work, how Can I do it? It will take much of my time if I have to do it manually as it is repeated procedures.

Thank you very much.

George

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @gtran and welcome to the SAS Support Communities!

 

If that constant number is contained in a variable of the input dataset (abc), you can use the WEIGHT statement to obtain the desired adjusted frequencies. Otherwise, you can add such a weight variable in a preliminary DATA step as shown below (creating a view to avoid redundancy), but for large input datasets it might be more efficient to multiply the frequencies in a subsequent DATA step using the mostly smaller output dataset (xyz) from PROC FREQ.

data _tmp / view=_tmp;
set sashelp.class;
_w=3.14;
run;

proc freq data=_tmp;
tables age*sex / out=want;
weight _w / zeros;
run;

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @gtran and welcome to the SAS Support Communities!

 

If that constant number is contained in a variable of the input dataset (abc), you can use the WEIGHT statement to obtain the desired adjusted frequencies. Otherwise, you can add such a weight variable in a preliminary DATA step as shown below (creating a view to avoid redundancy), but for large input datasets it might be more efficient to multiply the frequencies in a subsequent DATA step using the mostly smaller output dataset (xyz) from PROC FREQ.

data _tmp / view=_tmp;
set sashelp.class;
_w=3.14;
run;

proc freq data=_tmp;
tables age*sex / out=want;
weight _w / zeros;
run;
gtran
Calcite | Level 5

Thank you very much @FreelanceReinh for your prompt help. I tried your second option and it worked. 

Best 

George