Help using Base SAS procedures

Running Proc Freq;

Reply
N/A
Posts: 0

Running Proc Freq;

Hi,

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,777

Re: Running Proc Freq;

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.

[pre]
%let vars = _char_;

** data A the data to summarize;
data A;
set sashelp.shoes;
run;

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

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

ods listing close;
proc freq data=a;
tables &vars;
ods output &odsout;
run;
ods listing;
[/pre]
N/A
Posts: 0

Re: Running Proc Freq;

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
  • 119 views
  • 0 likes
  • 2 in conversation