Help using Base SAS procedures

Running Proc Freq;

Not applicable
Posts: 0

Running Proc Freq;


I would like to run a proc freq on data Set A by passing it a list of variables from Data Set B. The variables are in table A, however i need to output the results of the proc freq to a data set labelled the variable name.

I have written a macro, but i don't know how to call the variable names from the data set B.

Any assistance will be appreciated.
Respected Advisor
Posts: 3,852

Re: Running Proc Freq;

Posted in reply to deleted_user
In order to use the variables listed in B as code you can use PROC SQL to create macro variables. These macro variables become part of the PROC FREQ call.

Here is an example that puts the PROC FREQ output into dataset named using the analysis variable names.

%let vars = _char_;

** data A the data to summarize;
data A;

** data B a list of variable names;
proc transpose data=A(obs=0) out=B;
var _char_;

proc sql noprint;
select _name_ , cats('Freq.Table',monotonic(),'.OneWayFreqs=',_name_)
into :vars separated by ' ', Smiley Surpriseddsout separated by ' '
from b;
%put NOTE: VARS=&vars;
%put NOTE- ODSOUT=&odsout;

ods listing close;
proc freq data=a;
tables &vars;
ods output &odsout;
ods listing;
Not applicable
Posts: 0

Re: Running Proc Freq;

Posted in reply to data_null__
Thanks a a lot.. i really appreciate it. I am busy testing, and i will give u feedback.
So far it works perfectly, i just need to supress a few outputs.
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation