I have a list of variables stored in the macro &relevant vars. I want to see the mean value of each of these variables (spread across the columns) grouped by a variable called cluster.
I ran a code as follows :
proc tabulate data = work.cluster_data_with_var_pred; var CLUSTER; table (CLUSTER)*(MEAN), &relevant_vars; run;
It turns out that I cannot have the reference mentioned there. I tried a simple proc means but that creates a messy table where the relevant_vars just repeat rows for each cluster value instead of running across as columns Can anyone help me figure out another way to do this?
Oh yes! The proc tabulate you sent worked perfectly. I wanted the variable list to run along the columns, that's why I scrapped the proc means idea. Thank you so much!
I think what you want to do is this. I just replicated the problem using SASHELP.CLASS.
%let relevant_vars = height weight;
proc tabulate data = sashelp.class;
class sex;
var &relevant_vars;
table sex, (&relevant_vars)*mean;
run;
Result:
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.