UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS Code Fragments
Simple Macro to Do Repeated Procs

data xxx;
  input v1-v5 ind1 ind2;
  cards;
1 0 1 1 0 34 23
0 0 0 1 1 22 32
1 1 0 1 0 12 10
0 1 1 0 1 56 90
;
run;
%macro mylogit(num);
   %do i = 1 %to #
      proc logistic data=xxx des;
      model v&i = ind1 ind2;
      run;
%end;
%mend;
%mylogit(5)
/***another try with variable names*****/
%macro mylogit1(all_deps);
   %let k=1;
   %let dep = %scan(&all_deps, &k);
     %do %while(&dep NE);
        proc logistic data=xxx des;
        model &dep = ind1 ind2;
        run;
     %let k = %eval(&k + 1);
     %let dep = %scan(&all_deps, &k);
     %end;
%mend;

%mylogit1(v1 v2 v3)

%let test = v1 v2 v3 v4 v5;
%mylogit1(&test)

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California