Loop a delimited macrovariabel in SAS

This shows how to loop a delimited macrovariabel.

%let Delimitor = ¤;
%let Logins = Login1¤Login2;

%let NumberOfLogins = %sysfunc(countw(&Logins., &Delimitor.));
%put Number of logins: &NumberOfLogins.;

%macro _CreateLogin;

%do J=1 %to &NumberOfLogins;

%let Login = %scan(&Logins., &J, &Delimitor.);
%CreateLogin(_Login=&Login.);

 %end;

%mend;

%_CreateLogin;

One thought on “Loop a delimited macrovariabel in SAS”

  1. A couple of suggestions:

    1) Avoid using a language which is so shitty that it doesn’t even have a foreach loop.

    2) If you can’t avoid SAS then avoid creating global variables like delimitor and logins. Instead pass the values as parameters.

Leave a Reply to Morten Cancel reply

Your email address will not be published. Required fields are marked *