Loading...
Searching...
No Matches
getdata.sas
Go to the documentation of this file.
1/**
2 @file getdata.sas
3 @brief Returns a dataset to the editor front end
4 @details
5
6 <h4> Service Inputs </h4>
7
8 <h5> SASCONTROLTABLE </h5>
9 |LIBDS:$41.|FILTER_RK:$5.|
10 |---|---|
11 |DC258467.MPE_X_TEST|-1|
12
13 <h4> Service Outputs </h4>
14 <h5> sasdata </h5>
15 <h5> sasparams </h5>
16 Contains info on the request. One row is returned.
17 @li CLS_FLG - set to 0 if there are no CLS rules (everything editable)
18 else set to 1 (CLS rules exist)
19 @li ISMAP - set to 1 if the target DS is an excel map target, else 0
20
21 <h5> approvers </h5>
22 <h5> dqrules </h5>
23 <h5> dqdata </h5>
24 <h5> cols </h5>
25 Contains column level attributes.
26 @li NAME - column name
27 @li VARNUM - var position. https://core.sasjs.io/mp__getcols_8sas.html
28 @li LABEL - var label. https://core.sasjs.io/mp__getcols_8sas.html
29 @li FMTNAME - derived format. https://core.sasjs.io/mp__getcols_8sas.html
30 @li DDTYPE - derived dropdown. https://core.sasjs.io/mp__getcols_8sas.html
31 @li CLS_RULE - values include:
32 - EDIT - the column is editable
33 - READ - the column should be readonly
34 - HIDE - the column should be hidden
35 @li memlabel
36 @li desc- augmented with MPE_DATADICTIONARY if exists, else label
37 @li longdesc - from MPE_DATADICTIONARY
38
39
40 <h5> maxvarlengths </h5>
41 <h5> xl_rules </h5>
42 <h5> query </h5>
43
44 <h5> versions </h5>
45 history of DC versions for this particular table
46
47
48 <h4> SAS Macros </h4>
49 @li dc_assignlib.sas
50 @li dc_casload.sas
51 @li dc_getgroupmembers.sas
52 @li mf_existvar.sas
53 @li mf_getattrn.sas
54 @li mf_getvarlist.sas
55 @li mf_existds.sas
56 @li mf_getquotedstr.sas
57 @li mf_getuser.sas
58 @li mf_nobs.sas
59 @li mf_verifymacvars.sas
60 @li mf_wordsinstr1butnotstr2.sas
61 @li mp_abort.sas
62 @li mp_cntlout.sas
63 @li mp_getcols.sas
64 @li mp_getmaxvarlengths.sas
65 @li mp_validatecol.sas
66 @li mpe_accesscheck.sas
67 @li mpe_columnlevelsecurity.sas
68 @li mpe_dsmeta.sas
69 @li mpe_getlabels.sas
70 @li mpe_getversions.sas
71 @li mpe_filtermaster.sas
72 @li mpe_runhook.sas
73
74 @version 9.2
75 @author 4GL Apps Ltd
76 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
77 and may not be re-distributed or re-sold without the express permission of
78 4GL Apps Ltd.
79
80**/
81
82%mpeinit()
83
84/**
85 * Validate inputs
86 */
87data work.intest;
88 length filter_rk 8;
89 set work.SASCONTROLTABLE;
90
91 /* validate filter_rk */
92 if filter_rk le 0 then filter_rk=-1;
93
94 call symputx('orig_libds',upcase(libds));
95
96 is_fmt=0;
97 if substr(cats(reverse(libds)),1,3)=:'CF-' then do;
98 libds=scan(libds,1,'-');
99 putlog "Format Catalog Captured";
100 is_fmt=1;
101 libds='work.fmtextract';
102 call symputx('libds',libds);
103 end;
104 call symputx('is_fmt',is_fmt);
105 putlog (_all_)(=);
106
107 /* validate libds */
108 %mp_validatecol(LIBDS,LIBDS,is_libds)
109
110 if is_libds=0 then do;
111 putlog 'ERR' 'OR: Invalid libds:' libds;
112 stop;
113 end;
114 else do;
115 call symputx('filter_rk',filter_rk);
116 call symputx('libds',libds);
117 end;
118 output;
119 stop;
120run;
121
122%mp_abort(iftrue= (%mf_nobs(work.intest)=0)
123 ,mac=&_program
124 ,msg=%str(Some err with service inputs)
125)
126
127%mp_abort(
128 iftrue=(%mf_verifymacvars(libds filter_rk)=0)
129 ,mac=&_program
130 ,msg=%str(Missing: libds filter_rk)
131)
132
133/* export format catalog */
134%mp_cntlout(
135 iftrue=(&is_fmt=1)
136 ,libcat=&orig_libds
137 ,fmtlist=0
138 ,cntlout=work.fmtextract
139)
140
141/* stream back meta info, further calls will return col metadata and actual data
142*/
143%let libref=%upcase(%scan(&libds,1,.));
144%let dsn=%upcase(%scan(&libds,2,.));
145%dc_assignlib(WRITE,&libref)
146%dc_casload(&libds)
147
148/**
149 * First check user has access permission to edit the table
150 */
151%put checking access;
152%let user=%mf_getuser();
153%mpe_accesscheck(&orig_libds,outds=mw_auth,user=&user,access_level=EDIT)
154
155
156%mp_abort(iftrue= (%mf_getattrn(work.mw_auth,NLOBS)=0)
157 ,mac=mpestp_getdata.sas
158 ,msg=&user is not authorised to edit &orig_libds %trim(
159 )in the &mpelib..MPE_SECURITY table
160)
161
162%mp_abort(iftrue= ( %mf_existds(libds=&libds) ne 1)
163 ,mac=mpestp_getdata.sas
164 ,msg=dataset &libds does not exist!!
165)
166
167%mp_abort(iftrue= (&syscc ne 0)
168 ,mac=&_program..sas
169 ,msg=%str(syscc=&syscc at line 60 )
170)
171
172
173%global loadtype var_txfrom var_txto var_processed filter_text pk coltype
174 sortpk;
175
176%put getting table attributes;
177proc sql noprint;
178select upcase(loadtype)
179 ,var_txfrom,var_txto
180 ,var_busfrom,var_busto
181 ,var_processed,rk_underlying,buskey
182 ,coalesce(rk_underlying,buskey)
183 ,pre_edit_hook
184 ,case when missing(rk_underlying) then buskey else rk_underlying end
185 into: loadtype,:var_txfrom,:var_txto
186 ,:var_busfrom ,:var_busto
187 ,:var_processed,:rk_underlying,:buskey, :sortPK, :pre_edit_hook,:pk
188 from &mpelib..mpe_tables
189 where &dc_dttmtfmt. lt TX_TO
190 and upcase(dsn)="%scan(&orig_libds,2,.)"
191 and upcase(libref)="%scan(&orig_libds,1,.)";
192
193%put preparing filter query:;
194%mpe_filtermaster(EDIT,&orig_libds,
195 dclib=&mpelib,
196 filter_rk=&filter_rk,
197 outref=filtref,
198 outds=work.query
199)
200
201%macro mpestp_getdata();
202 %if not %symexist(DC_MAXOBS_WEBEDIT) %then %do;
203 %put NOTE:;%put NOTE- DC_MAXOBS_WEBEDIT not found!;
204 %put NOTE- Please add to &mpelib..MPE_CONFIG table;
205 %put NOTE-;%put NOTE-;
206 %global DC_MAXOBS_WEBEDIT;
207 %let DC_MAXOBS_WEBEDIT=500;
208 %end;
209 /* for tables which use RKs/SKs then we just expose the business key to
210 users - this lets uploads be sent to multiple environments (with
211 potentially different RK/SK values for the same business key).
212 Note that the config table has the RK column in the buskey field in
213 this scenario. */
214 %if %length(&rk_underlying)>0 %then %let drop_rk=&buskey;
215 %else %let drop_rk=;
216
217 /* always remove the PROCESSED_DTTM column, if it exists */
218 %if %length(&var_processed)=0 %then %do;
219 %if %mf_existvar(&libds,PROCESSED_DTTM)>0 %then
220 %let var_processed=PROCESSED_DTTM;
221 %end;
222
223 /**
224 * Now get the slice of the actual table
225 */
226 options obs=10000;
227
228 %if &loadtype=BITEMPORAL %then %do;
229 data out (drop=&var_txfrom &var_txto &var_processed &drop_rk );
230 _____DELETE__THIS__RECORD_____="No";
231 set &libds;
232 where %inc filtref;;
233 run;
234 proc sort data=out;
235 by &pk &var_busfrom;
236 run;
237 data out;
238 set out;
239 by &pk &var_busfrom;
240 if last.%scan(&pk,-1);
241 run;
242 %end;
243 %else %do;
244 data out (drop=&var_txfrom &var_txto &var_processed &drop_rk);
245 _____DELETE__THIS__RECORD_____="No";
246 set &libds;
247 where %inc filtref;;
248 run;
249 %end;
250 options obs=max;
251 %mp_abort(iftrue= (&syscc ne 0)
252 ,mac=&_program
253 ,msg=%str(Issue with filtering (line 165) )
254 )
255
256 options obs=&DC_MAXOBS_WEBEDIT;
257 %let sortpk=%sysfunc(coalescec(&sortpk &var_busfrom,_ALL_));
258 proc sort data=work.out; by &sortPK; run;
259 options obs=max;
260
261 %mpe_runhook(PRE_EDIT_HOOK)
262
263 %let obscnt=%mf_getattrn(work.out,NLOBS);
264 %mp_abort(iftrue=(&obscnt>&DC_MAXOBS_WEBEDIT)
265 ,mac=&_program
266 ,msg=Table is too big (&obscnt rows) - please filter and try again!
267 )
268
269
270 /* order delete var and pk fields at start of table */
271 %let sourcevars=%mf_wordsInStr1ButNotStr2(
272 Str1=%mf_getvarlist(work.out)
273 ,Str2= _____DELETE__THIS__RECORD_____ &pk
274 );
275 %put sourcevars=&sourcevars;
276 data outdata;
277 /* delete & pk fields come first */
278 attrib _____DELETE__THIS__RECORD_____ &pk label='';
279 /* keep remaining variable order */
280 %if %length(&sourcevars)>0 %then %do;
281 attrib &sourcevars label='';
282 %end;
283 _____DELETE__THIS__RECORD_____="No ";
284 %if %mf_nobs(work.out)=0 %then %do;
285 /* send empty row if empty table to help with hot rendering */
286 output;
287 %end;
288 set work.out ;
289 run;
290
291
292
293 /* get list of variables and their formats */
294 proc contents noprint data=outdata
295 out=vars(keep=name type length varnum format: label);
296 run;
297
298 proc sort;
299 by varnum;
300 run;
301
302 data vars3(keep=name type length format label pk varnum ctrloptions formatd);
303 set vars(rename=(format=format2 type=type2));
304 name=upcase(name);
305 /* not interested in transaction or processing dates
306 (append table must be supplied without them) */
307 if name not in ("&VAR_TXFROM","&VAR_TXTO","&VAR_PROCESSED");
308 if type2=2 or type2=6 then do;
309 length format $49.;
310 if format2='' then format=cats('$',length,'.');
311 else format=cats(format2,formatl,'.');
312 type='char';
313 end;
314 else do;
315 if format2='' then format=cats(length,'.');
316 else if upcase(format2)='DATETIME' and formatl=0 then format='DATETIME.';
317 else format=cats(format2,formatl,'.',formatd);
318 type='num';
319 end;
320
321 if name in ('',%upcase(%mf_getQuotedStr(&pk,dlm=%str(,),quote=S)))
322 then PK='YES';
323
324 length ctrlOptions $500;
325 if name="_____DELETE__THIS__RECORD_____" then ctrlOptions='["No","Yes"]';
326 else ctrlOptions='';
327 run;
328 %mp_abort(iftrue= (&syscc ne 0)
329 ,mac=&_program..sas
330 ,msg=%str(syscc=&syscc at 242 (vars3 step) in &_program \n
331 %superq(syserrortext)
332 )
333 )
334
335 %global jsdttmvars jsdtvars jstmvars;
336 data _null_;
337 set vars3 end=last;
338 if _n_>1 then comma=',';
339 length coltype $500.;
340 format=upcase(format);
341 coltype=cats(comma,'{"data":"',name,'"');
342 if ctrlOptions ne '' then
343 colType=cats(coltype,',"type":"dropdown","source":',ctrlOptions,"}");
344 else if type='num' then do;
345 if format=:'DATETIME' or format=:'E8601DT' or format=:'NLDATM'
346 then do;
347 colType=cats(coltype
348 ,',"type":"date","dateFormat":"YYYY-MM-DD HH:mm:ss"'
349 ,',"correctFormat":"true"}');
350 /* build var list to reformat datetimes in javascript format */
351 call symput('jsdttmvars',symget('jsdttmvars')!!' '!!name);
352 end;
353 else if format=:'DATE' or format=:'DDMMYY' or format=:'MMDDYY'
354 or format=:'YYMMDD' or format=:'E8601DA' or format=:'B8601DA'
355 or format=:'MONYY' or format=:'NLDATE'
356 then do;
357 /* see bottom of file for more date formats!! */
358 /* also when updating, update stagedata.sas and mp_getcols.sas
359 and mpe_loader.sas */
360 colType=cats(coltype,',"type":"date","dateFormat":"YYYY-MM-DD"'
361 /*colType=cats(coltype,',"type":"date","dateFormat":"MM/DD/YYYY"'*/
362 ,',"correctFormat":"true"}');
363 /* build var list to reformat as javascript dates */
364 call symput('jsdtvars',symget('jsdtvars')!!' '!!name);
365 end;
366 else if format=:'TIME' or format=:'HHMM' then do;
367 colType=cats(coltype,',"type":"time","timeFormat":"HH:mm:ss"'
368 ,',"correctFormat":"true"}');
369 /* build var list to reformat as javascript times */
370 call symput('jstmvars',symget('jstmvars')!!' '!!name);
371 end;
372 else do;
373 /* is standard numeric but need to ascertain precision */
374 retain base '000000000000000000';
375 if formatd>0 then numFormat=cats('.',substr(base,1,formatd));
376 colType=cats(coltype,',"type":"numeric","format":"0',numFormat,'"}');
377 end;
378 end;
379 else colType=cats(coltype,'}');
380 length concatcoltype $32767;
381 retain concatcoltype;
382 concatcoltype=cats(concatcoltype,coltype);
383 if last then call symputx('colType',strip(concatcoltype),'g');
384 putlog (_all_)(=);
385 run;
386
387 %mp_abort(iftrue= (&syscc ne 0)
388 ,mac=&_program..sas
389 ,msg=%str(syscc=&syscc at 283 (null step) in &_program)
390 )
391
392 PROC FORMAT;
393 picture yymmddThhmmss (default=28) other='%0Y-%0m-%0d %0H:%0M:%0s'
394 (datatype=datetime);
395 picture JSyymmdd other='%0Y-%0m-%0d' (datatype=date);
396 picture JShhmmss (default=16) other='%0H:%0M:%0s' (datatype=time);
397 RUN;
398 /* before we send the data, need to rebuild all date & datetime vars as char*/
399 %let finalvars=%mf_getvarlist(work.outdata);
400 data sasdata;
401 /* set formats & col order ahead of rename+import */
402 informat &finalvars ;
403 /* read dataset and rename date / datetime vars as necessary */
404 set outdata
405 %if %length(&jsdttmvars&jsdtvars&jstmvars)>0 %then %do;
406 (rename=(
407 %local dtvarnum dtvar tmvar;
408 /* temp datetime vars end in _____ */
409 %do dtvarnum=1 %to %sysfunc(countw(&jsdttmvars,%str( )));
410 %let dtvar=%scan(&jsdttmvars ,&dtvarnum);
411 &dtvar=_____&dtvarnum._____
412 %end;
413 /* temp date vars do not end in _____ */
414 %do dtvarnum=1 %to %sysfunc(countw(&jsdtvars,%str( )));
415 %let dtvar=%scan( &jsdtvars,&dtvarnum);
416 &dtvar=_____&dtvarnum
417 %end;
418 /* temp time vars end in ___tm */
419 %do tmvarnum=1 %to %sysfunc(countw(&jstmvars,%str( )));
420 %let tmvar=%scan( &jstmvars,&tmvarnum);
421 &tmvar=_____&tmvarnum.___tm
422 %end;
423 ))
424 %end;
425 ;
426 %if %length(&jsdttmvars)>0 %then %do ;
427 %do dtvarnum=1 %to %sysfunc(countw(&jsdttmvars,%str( )));
428 %let dtvar=%scan(&jsdttmvars,&dtvarnum);
429 &dtvar=cats(put(_____&dtvarnum._____,yymmddThhmmss28.));
430 if &dtvar="ERROR" then call missing(&dtvar);
431 drop _____&dtvarnum._____;
432 %end;
433 %end;
434 %if %length(&jsdtvars)>0 %then %do;
435 %do dtvarnum=1 %to %sysfunc(countw(&jsdtvars,%str( )));
436 %let dtvar=%scan(&jsdtvars,&dtvarnum);
437 &dtvar=cats(put(_____&dtvarnum,JSyymmdd.));
438 if &dtvar="ERROR" then call missing(&dtvar);
439 drop _____&dtvarnum;
440 %end;
441 %end;
442 %if %length(&jstmvars)>0 %then %do;
443 %do tmvarnum=1 %to %sysfunc(countw(&jstmvars,%str( )));
444 %let tmvar=%scan(&jstmvars,&tmvarnum);
445 &tmvar=cats(put(_____&tmvarnum.___tm,JShhmmss14.));
446 if &tmvar="ERROR" then call missing(&tmvar);
447 drop _____&tmvarnum.___tm;
448 %end;
449 %end;
450 output;
451 run;
452
453 /* get the relevant approvers for the drop down */
454 %put getting approvers;
455 %local sas_groups sas_i sas_group;
456 proc sql noprint;
457 select distinct sas_Group into: sas_groups separated by "|"
458 from &mpelib..mpe_security
459 where libref="%scan(&orig_libds,1,.)"
460 and dsn="%scan(&orig_libds,2,.)"
461 and access_level='APPROVE'
462 and &dc_dttmtfmt. lt TX_TO;
463
464 %if %length(&sas_groups)=0 %then %do;
465 %dc_getgroupmembers(&dc_admin_group,outds=work.access1)
466 %end;
467 %else %do sas_i=1 %to %sysfunc(countw(&sas_groups,%str(|)));
468 %let sas_group=%scan(&sas_Groups,&sas_i,%str(|));
469 %dc_getgroupmembers(&sas_group,outds=work.temp&sas_i)
470 proc append base=work.access1 data=work.temp&sas_i;run;
471 %end;
472
473%mend mpestp_getdata;
474
475%mpestp_getdata()
476
477%mp_abort(mode=INCLUDE)
478
479/* extract column level security rules */
480%mpe_columnlevelsecurity(%scan(&libds,1,.),%scan(&libds,2,.),work.sasdata
481 ,mode=EDIT
482 ,clsds=&mpelib..mpe_column_level_security
483 ,groupds=work.groups /* was created in mpe_filtermaster */
484 ,outds=work.sasdata1
485 ,outmeta=work.cls_rules
486)
487
488/* get labels */
489%mpe_getlabels(COLUMNS,sasdata1,outds=spec)
490%mp_abort(iftrue= (&syscc ne 0)
491 ,mac=&_program
492 ,msg=%str(syscc=&syscc extracting spec info)
493)
494
495/* extract col info */
496%mp_getcols(&libds, outds=cols1)
497
498/* join with cls rules */
499proc sql;
500create table work.cols as
501 select a.NAME
502 ,a.VARNUM
503 ,a.LABEL
504 ,a.FMTNAME
505 ,a.DDTYPE
506 ,case b.cls_hide
507 when 1 then 'HIDE'
508 when 0 then 'EDIT'
509 else 'READ' end as CLS_RULE
510 ,c.memlabel
511 ,c.desc
512 ,c.longdesc
513 from work.cols1 a
514 left join work.cls_rules b
515 on a.NAME=b.CLS_VARIABLE_NM
516 left join work.spec c
517 on a.NAME=c.NAME;
518
519proc sql;
520create table approvers as select distinct membername as personname
521 ,membername as email, membername as userid
522 from work.access1;
523/*
524create table access3 as select b.userid,b.email
525 from access2 a
526 ,support.users b
527 where a.personname=b.userid
528 and a.personname ne "%mf_getuser()"
529 and %sysfunc(datetime()) lt b.tx_to_dttm
530 order by 1;
531*/
532data _null_;
533 infile filtref end=eof;
534 input;
535 length filter_text $32767;
536 retain filter_text;
537 filter_text=catx(' ',filter_text,_infile_);
538 if eof then do;
539 if cats(filter_text)='1=1' then filter_text='';
540 call symputx('filter_text',filter_text);
541 end;
542run;
543
544%put params;
545%let ismap=0;
546proc sql noprint;
547select count(*) into: ismap from &mpelib..mpe_xlmap_info
548 where XLMAP_TARGETLIBDS="&orig_libds" and &dc_dttmtfmt. le TX_TO;
549
550data sasparams;
551 length colHeaders $20000 filter_text $32767;
552 colHeaders=cats(upcase("%mf_getvarlist(sasdata1,dlm=%str(,))"));
553 pkCnt=countw("&pk");
554 pk="&pk";
555 dtvars=compbl("&jsdtvars");
556 dttmvars=compbl("&jsdttmvars");
557 tmvars=compbl("&jstmvars");
558 length coltype $32000;
559 coltype=symget('coltype');
560 loadtype=symget('loadtype');
561 if trim(symget('rk_underlying')) ne '' then rk_flag=1;
562 else rk_flag=0;
563 filter_text=symget('filter_text');
564 if %mf_nobs(work.cls_rules)=0 then cls_flag=0;
565 else cls_flag=1;
566 put (_all_)(=);
567 if "&orig_libds"="&mpelib..MPE_XLMAP_DATA" or &ismap ne 0 then ismap=1;
568 else ismap=0;
569run;
570
571
572/* Extract validation DQ Rules */
573proc sort data=&mpelib..mpe_validations
574 (where=(&dc_dttmtfmt. le TX_TO
575 and BASE_LIB="%scan(&orig_libds,1,.)" and BASE_DS="%scan(&orig_libds,2,.)"
576 and rule_active=1))
577 out=dqrules (keep=base_col rule_type rule_value);
578 by base_col rule_type rule_value;
579run;
580
581/* merge with NOTNULL constraints in the physical table */
582proc sql;
583create table _data_ as
584 select * from dqrules
585union
586 select upcase(name) as base_col
587 ,'NOTNULL' as rule_type
588 ,'' as rule_value
589 from dictionary.columns
590 where upcase(libname)="%scan(&orig_libds,1,.)"
591 and upcase(memname)="%scan(&orig_libds,2,.)"
592 and upcase(name) in (select name from vars3)
593 and notnull='yes'
594 order by 1,2,3;
595data dqrules;
596 set &syslast;
597 by base_col rule_type rule_value;
598 if last.rule_type;
599 if rule_type in ('HARDSELECT','SOFTSELECT') and countw(rule_value)=3 then
600 do;
601 retain x 0; x+1;
602 call symputx(cats('source',x),rule_value);
603 %let sourcecnt=0;
604 call symputx('sourcecnt',x);
605 call symputx(cats('base_col',x),base_col);
606 end;
607run;
608
609proc sql;
610create table dqdata as
611 select distinct base_column as base_col length=32
612 ,upcase(base_column) as rule_value length=74 /* deprecated */
613 ,selectbox_value as rule_data length=1000
614 ,selectbox_order
615 from &mpelib..mpe_selectbox
616 where &dc_dttmtfmt. lt ver_to_dttm
617 and select_lib="%scan(&orig_libds,1,.)"
618 and select_ds="%scan(&orig_libds,2,.)";
619
620%mp_abort(iftrue= (&syscc ne 0)
621 ,mac=&_program
622 ,msg=%str(syscc=&syscc during DQ rule validation)
623)
624
625/* extract selectbox data */
626%macro dq_selects();
627 %local x source lib ds col;
628 %do x=1 %to &sourcecnt;
629 %let source=&&source&x;
630 %let lib=%scan(&source,1,.);
631 %let ds=%scan(&source,2,.);
632 %let col=%scan(&source,3,.);
633 %put &=source;
634 %put &=lib;
635 %dc_assignlib(READ,&lib)
636 proc sql;
637 create table dqdata&x as
638 select distinct "&&base_col&x" as base_col length=32
639 ,"&source" as rule_value length=74
640 ,cats(&col) as rule_data length=1000
641 ,&col as tmp_order
642 from &lib..&ds
643 order by tmp_order;
644 /* ensure both numerics and char vals are ordered correctly */
645 data work.dqdata&x (drop=tmp_order);
646 set work.dqdata&x;
647 selectbox_order=_n_;
648 run;
649 %mp_abort(iftrue= (&syscc ne 0)
650 ,mac=&_program
651 ,msg=%str(syscc=&syscc when selecting &&base_col&x from &orig_libds)
652 )
653 proc append base=dqdata data=dqdata&x;run;
654 proc sql; drop table dqdata&x;
655 %end;
656%mend dq_selects;
657%dq_selects()
658
659proc sort data=dqdata;
660 /* order by selectbox_order then the value */
661 by base_col selectbox_order rule_data;
662run;
663
664%mp_getmaxvarlengths(work.sasdata1,outds=maxvarlengths)
665
666data maxvarlengths;
667 set maxvarlengths;
668 if name='_____DELETE__THIS__RECORD_____' then mAXLEN=3;
669run;
670
671data xl_rules;
672 set &mpelib..mpe_excel_config;
673 where &dc_dttmtfmt. lt tx_to;
674 where also upcase(xl_libref)="%scan(&orig_libds,1,.)";
675 where also upcase(xl_table)="%scan(&orig_libds,2,.)";
676 where also xl_active=1;
677 keep xl_column xl_rule;
678run;
679
680%mpe_dsmeta(&orig_libds, outds=dsmeta)
681
682%mpe_getversions(&mpelib,
683 %scan(&orig_libds,1,.),
684 %scan(&orig_libds,2,.),
685 outds=versions
686)
687
688
689/* send to the client */
690%webout(OPEN)
691%webout(OBJ,approvers)
692%webout(OBJ,cols)
693%webout(OBJ,dqdata,missing=STRING)
694%webout(OBJ,dqrules)
695%webout(OBJ,dsmeta)
696%webout(OBJ,maxvarlengths)
697%webout(OBJ,query)
698%webout(OBJ,sasdata1,fmt=N,missing=STRING,showmeta=YES,dslabel=sasdata)
699%webout(OBJ,sasparams)
700%webout(OBJ,versions)
701%webout(OBJ,xl_rules)
702%webout(CLOSE)
703
704/*
705$N8601Bw
706$N8601BAw
707$N8601Ew
708$N8601EAw
709$N8601EHw
710$N8601EXw
711$N8601Hw
712$N8601Xw
713B8601DAw
714B8601DNw
715B8601DTw
716B8601DZw
717B8601LZw
718B8601TMw
719B8601TZw
720DATEw
721DATEAMPMw
722DATETIMEw
723DAYw
724DDMMYYw
725DDMMYYxw
726DOWNAMEw
727DTDATEw
728DTMONYYw
729DTWKDATXw
730DTYEARw
731DTYYQCw
732E8601DAw
733E8601DNw
734E8601DTw
735E8601DZw
736E8601LZw
737E8601TMw
738E8601TZw
739HHMMw
740HOURw
741JULDAYw
742JULIANw
743MMDDYYw
744MMDDYYxw
745MMSSw
746MMYYw
747MMYYxw
748MONNAMEw
749MONTHw
750MONYYw
751PDJULGw
752PDJULIw
753QTRw
754QTRRw
755TIMEw
756TIMEAMPMw
757TODw
758WEEKDATEw
759WEEKDATXw
760WEEKDAYw
761WEEKUw
762WEEKVw
763WEEKWw
764WORDDATEw
765WORDDATXw
766YEARw
767YYMMw
768YYMMxw
769YYMMDDw
770YYMMDDxw
771YYMONw
772YYQw
773YYQxw
774YYQRw
775YYQRxw
776$N8601BAw
777$N8601Ew
778$N8601EAw
779$N8601EHw
780$N8601EXw
781$N8601Hw
782$N8601Xw
783B8601DAw
784B8601DNw
785B8601DTw
786B8601DZw
787B8601LZw
788B8601TMw
789B8601TZw
790E8601DAw
791E8601DNw
792E8601DTw
793E8601DZw
794E8601LZw
795E8601TMw
796E8601TZw
797*/
798%mpeterm()