registeruser.sas
Go to the documentation of this file.
1 /**
2  @file registeruser.sas
3  @brief Registers a new user in Data Controller
4  @details New users are logged after accepting EULA terms.
5 
6  <h4> SAS Macros </h4>
7  @li mf_getuser.sas
8  @li mp_abort.sas
9  @li mpeinit.sas
10 
11  @version 9.2
12  @author 4GL Apps Ltd
13  @copyright 4GL Apps Ltd. This code may only be used within Data Controller
14  and may not be re-distributed or re-sold without the express permission of
15  4GL Apps Ltd.
16 **/
17 
18 %mpeinit()
19 
20 %let userid=%mf_getuser();
21 
22 /* confirm the user is not registered */
23 %let isRegistered=0;
24 proc sql noprint;
25 select count(*) into: isregistered
26  from &mpelib..mpe_users
27  where user_id="&userid";
28 
29 %mp_abort(iftrue= (&syscc ne 0)
30  ,mac=&_program..sas
31  ,msg=%str(Problem accessing &mpelib..mpe_users table)
32 )
33 %mp_abort(iftrue= (&isregistered > 0)
34  ,mac=&_program..sas
35  ,msg=%str(User &userid is already registered on &mpelib..mpe_users!)
36 )
37 
38 data work.append;
39  if 0 then set &mpelib..mpe_users;
40  user_id=symget('userid');
41  registered_dt=today();
42  last_seen_dt=today();
43 run;
44 
45 proc append base=&mpelib..mpe_users data=work.append;
46 
47 %let isRegistered=0;
48 proc sql noprint;
49 select count(*) into: isregistered
50  from &mpelib..mpe_users
51  where user_id="&userid";
52 
53 %mp_abort(iftrue= (&syscc ne 0 or &isregistered ne 1)
54  ,mac=&_program..sas
55  ,msg=%str(Problem appending to &mpelib..mpe_users table)
56 )
57 
58 data work.return;
59  msg='SUCCESS';
60 run;
61 
62 %webout(OPEN)
63 %webout(OBJ,return)
64 %webout(CLOSE)