macros - Feeding multiple variables to the same univariate model, one by one at a time in SAS -
I am a new user for SAS. I'm trying to do many simple but exploratory unvivative analysis using linear regression. I was hoping to find more efficient ways to write SAS code. For example, what I have in my mind is the following:
proc reg data = test; Model BMI = Age; Model BMI = Calparde; Model BMI = Exercise; Model BMI = (etc ....); Run; But I can have 20 other predicted variables, and I do not list them one by one. PROC CORR will only give a correlation and P-value, but I really want to see the rest of the distribution as well. I know that if I use the macro I can make it a bit smaller:
% macro universe (var); Proc reg data = test; Model BMI = & amp; Var; Run; % Mandal Universe; % Univar (age); % Univar (calperday); % Univar (etc.); But it still needs to list all the variables one by one, but since they are all listed in the continuous sequence of data files, is there any better way? Thanks!
Flip your data instead so that you can use BY group processing. It only works when you have all the numerical variables Like to save me like macros
flip data sets; Data class; Set sashelp.class; Array Wars (*) _numeric_; Do I = 1 slow (Wars); Var_name = vname (wars (i)); Value = wars (i); Output; End; Keep the weight var_name value; Run; * Sort by processing; Proc Sort Data = Class; By Var_name; Run; Proc reg data = square; By Var_name; Where less (var_name) has 'weight'; Model weight = value; Run;
Comments
Post a Comment