BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
2 REPLIES 2
data_null__
Jade | Level 19
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 ' ', :odsout 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]
deleted_user
Not applicable
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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 859 views
  • 0 likes
  • 2 in conversation