-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathaddsasauto.sas
64 lines (44 loc) · 2.22 KB
/
addsasauto.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
%macro AddSASAuto(ref) / des="Add a fileref to the SASAutos option";
/********************************************************************************
BEGIN MACRO HEADER
********************************************************************************
Name: AddSASAuto
Author: Chris Swenson
Created: 2010-10-18
Purpose: Add a fileref to the SAS autocall macro option (SASAUTOS)
Arguments: ref - one or more filerefs to add to the option
Revisions
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Date Author Comments
¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯
2011-08-19 CAS Revised to scan through argument to match the order
specified by the user.
YYYY-MM-DD III Please use this format and insert new entries above
********************************************************************************
END MACRO HEADER
********************************************************************************/
%let ref=%upcase(&ref);
%if "%superq(ref)"="" %then %do;
%put %str(E)RROR: No arguments specified.;
%return;
%end;
%local count sasautos addref i current changed;
%let count=%sysfunc(countw(&ref, %str( )));
%put NOTE: &COUNT references specified.;
%let sasautos=%upcase(%sysfunc(getoption(sasautos)));
%if "%substr(&SASAUTOS, 1, 1)"="("
%then %let sasautos=%substr(&SASAUTOS, 2, %length(&SASAUTOS)-2);
%do i=&COUNT %to 1 %by -1;
%let current=%scan(&ref, &i, %str( ));
%if %sysfunc(fileref(¤t)) ne 0 %then %do;
%put %str(E)RROR: Specified fileref ¤t does not exist.;
%return;
%end;
%let changed=%sysfunc(tranwrd(&sasautos, %str( ), %str(*)));
%if %index(*&CHANGED*,*&CURRENT*)>0
%then %put NOTE: Specified fileref ¤t is already specified on the SASAUTOS option.;
%else %let addref=¤t &addref;
%end;
option sasautos=(&addref &sasautos);
%put NOTE: SAS Autocall Option (SASAutos) = %sysfunc(getoption(sasautos));
%mend AddSASAuto;