Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automate proc probits with do loops?

Status
Not open for further replies.

boywonder410

Instructor
Sep 7, 2008
1
US
I am doing bivariate research and I run about four or five (depending upon my mood) probits on a set of data, the probits send their results to a sas dataset (using ODS) and then I merge the datasets, eventually going to be thrown into an excel file.

here's the problem, my code is WAY long, each probit being written manually, even though the independent variables dont change, and I already have them all running off of a macro variable &independentvariables.

My question is, if ARRAY can only be used in data sets, isn't there any way to just make a list of independent variables and have the same code executed with respect to a number of different independent variables?
 
I don't know anything about probits, however, I think what you have here is a good spot to use some macro code.
Code:
%macro doloop(varlist);
  %do %for i = 1 %to 20;
    %let var = %scan(&VARLIST,&i);
    %put Running loop (&i) for variable &VAR;

    your code using the variable.

  %end;
%mend doloop;

%doloop(variable1 variable2 variable3);

This should get you on the right track. Check the macro processing doco for correct usage of the %do .. %for .. %to construction if it doesn't work. Also check the %scan function if there's a problem. I literally just pulled this off the top of my head.


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top