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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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