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;

Adding path to SASAUTOS

From SAS9.2 it’s possible to add a path to eg SASAUTOS. It’s done using ‘insert’ or ‘append’.
Read more about append and insert.

options insert=(sasautos=&SASProgramPath.\Macros);

If you get a strange error, that insert isn’t recognized or something like that. The error might be caused because there’s spaces in the path, that your trying to insert.

Getting path for the SAS-program being executed

/* Gets path for the SAS-program being executed */

%macro GetSASProgramPath;
%qsubstr(%sysget(SAS_EXECFILEPATH),1,%length(%sysget(SAS_EXECFILEPATH))-%length(%sysget(SAS_EXECFILEname)));
%mend;

%let SASProgramPath = %GetSASProgramPath;

This will only work on Windows.

In batchmode you can get the programname with the code below. This will  work in eg an AIX environment.

%let ProgramName = %sysfunc(getoption(sysin));
%put &ProgramName;