-
Notifications
You must be signed in to change notification settings - Fork 22
/
RSUBMIT.sas
94 lines (74 loc) · 1.77 KB
/
RSUBMIT.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
Author: Edwin Hu
Date: 2013-05-24
RSUBMIT Library for SAS
*/
%MACRO SIGNON(
ident=~/.ssh/wrds_pass.sas,
server=wrds.wharton.upenn.edu,
port=4016,
user=eddyhu
);
/*
# SIGNON #
## Summary ##
Remote submit signon wrapper.
## Variables ##
- ident: identity file location
- server: server address
- port: server port
- user: user name
## Usage ##
```
%IMPORT "~/git/sas/RSUBMIT.sas";
%SIGNON(
ident=~/.ssh/wrds_pass.sas,
server=wrds.wharton.upenn.edu,
port=4016,
user=eddyhu
);
```
*/
SIGNOFF;
%INCLUDE "&ident.";
options comamid=TCP remote=&server. &port.;
signon username="&user." password="&wrds_pass.";
%MEND;
%MACRO RSUBMIT(dir=);
/*
# RSUBMUT #
## Summary ##
Remote submit wrapper.
## Variables ##
- dir: remote directory
## Usage ##
```
%IMPORT "~/git/sas/RSUBMIT.sas";
%SIGNON(dir=/sastemp7/eh7/
);
```
*/
/* Set remote directory on server side */
%syslput remote_dir=&dir;
RSUBMIT;
/* Check if directory exists on the remote server and if not create it and set the library */
/* Also set home directory, other libraries, etc. */
%MACRO init(dir=) ;
/**/
%LOCAL rc fileref ;
%LET rc = %SYSFUNC(filename(fileref,&remote_dir)) ;
%IF %SYSFUNC(fexist(&fileref)) %THEN
%PUT NOTE: The directory "&remote_dir" exists ;
%ELSE
%DO ;
%SYSEXEC mkdir &remote_dir ;
%PUT %SYSFUNC(sysmsg()) The directory dhas been created. ;
%END ;
%LET rc=%SYSFUNC(filename(fileref)) ;
%MEND init ;
/* Note: this is done on the server side */
%init(dir=&remote_dir.);
libname out &remote_dir.;
options user="&remote_dir.";
libname home "~";
%MEND RSUBMIT;