View Full Version : By Type Macro


hockeyfan
02-07-2009, 09:43 PM
I am not looking for the actual solution to this problem, but just a little intuition on how one would solve the problem.

I want to write a macro that reads my data, and goes through each variable and does either a proc means statement or a proc freq statement depending on the variable type (means if continuous, freq if categorical).

I usually have datasets that have about 20 demographic/baseline variables that I need to get summary information, and I feel like I am not using my time most efficiently if I go through the SAS dataset and pick out the categorical or continuous variables.

Any guidance would be greatly appreciated, especially regarding how difficult this would be to implement.

Thanks (GO SABRES)!!

vinux
02-08-2009, 09:04 PM
It is not difficult..
You can create a macro and give the argument as the input data source.
Then use _CHAR_ and _NUMERIC_

proc means;
var _NUMERIC_;
run;
proc freq;
var _CHAR_;
run;

hockeyfan
02-09-2009, 09:28 PM
Can I use the same notation for other procedures?

ie
proc glm;
class _CHAR_;
model y=_CHAR_ _NUMERIC_;
run;