@sasjs/core 4.18.6 → 4.18.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,7 +106,7 @@
106
106
 
107
107
  proc compare
108
108
  base=&scopeds(where=(upcase(name) not in (%mf_getquotedstr(&ilist))))
109
- compare=&ds;
109
+ compare=&ds noprint;
110
110
  run;
111
111
 
112
112
  %if &sysinfo=0 %then %do;
@@ -152,6 +152,7 @@ run;
152
152
  data &out_ds;
153
153
  set &out_ds;
154
154
  length infoname infoval $60 fref $8;
155
+ if _n_=1 then call missing(fref);
155
156
  rc=filename(fref,filepath);
156
157
  drop rc infoname fid i close fref;
157
158
  if file_or_folder='file' then do;
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "@sasjs/cli": "3.6.0",
37
37
  "@sasjs/core": "4.4.7"
38
38
  },
39
- "version": "4.18.6"
39
+ "version": "4.18.9"
40
40
  }
@@ -11,6 +11,9 @@
11
11
  @param [out] outref= (msgetfil) The fileref to contain the file.
12
12
  @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
13
13
 
14
+ <h4> SAS Macros </h4>
15
+ @li mf_getuniquefileref.sas
16
+ @li mf_getuniquename.sas
14
17
 
15
18
  **/
16
19
 
@@ -19,14 +22,20 @@
19
22
  ,mdebug=0
20
23
  );
21
24
 
22
- filename &outref temp;
25
+ /* use the recfm in a separate fileref to avoid issues with subsequent reads */
26
+ %local binaryfref floc;
27
+ %let binaryfref=%mf_getuniquefileref();
28
+ %let floc=%sysfunc(pathname(work))/%mf_getuniquename().txt;
29
+ filename &outref "&floc";
30
+ filename &binaryfref "&floc" recfm=n;
23
31
 
24
- proc http method='GET' out=&outref
32
+ proc http method='GET' out=&binaryfref
25
33
  url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
26
34
  %if &mdebug=1 %then %do;
27
35
  debug level=2;
28
36
  %end;
29
37
  run;
30
38
 
39
+ filename &binaryfref clear;
31
40
 
32
41
  %mend ms_getfile;
@@ -461,7 +461,7 @@ data _null_;
461
461
  put ' sasjs_tables SYS_JES_JOB_URI; ';
462
462
  put '%if %index("&_debug",log) %then %let _debug=131; ';
463
463
  put ' ';
464
- put '%local i tempds; ';
464
+ put '%local i tempds table; ';
465
465
  put '%let action=%upcase(&action); ';
466
466
  put ' ';
467
467
  put '%if &action=FETCH %then %do; ';
@@ -476,60 +476,35 @@ data _null_;
476
476
  put ' %end; ';
477
477
  put ' ';
478
478
  put ' /* if the sasjs_tables param is passed, we expect param based upload */ ';
479
- put ' %if %length(&sasjs_tables.XX)>2 %then %do; ';
480
- put ' filename _sasjs "%sysfunc(pathname(work))/sasjs.lua"; ';
481
- put ' data _null_; ';
482
- put ' file _sasjs; ';
483
- put ' put ''s=sas.symget("sasjs_tables")''; ';
484
- put ' put ''if(s:sub(1,7) == "%nrstr(")''; ';
485
- put ' put ''then''; ';
486
- put ' put '' tablist=s:sub(8,s:len()-1)''; ';
487
- put ' put ''else''; ';
488
- put ' put '' tablist=s''; ';
489
- put ' put ''end''; ';
490
- put ' put ''for i = 1,sas.countw(tablist) ''; ';
491
- put ' put ''do ''; ';
492
- put ' put '' tab=sas.scan(tablist,i)''; ';
493
- put ' put '' sasdata=""''; ';
494
- put ' put '' if (sas.symexist("sasjs"..i.."data0")==0)''; ';
495
- put ' put '' then''; ';
496
- put ' /* TODO - condense this logic */ ';
497
- put ' put '' s=sas.symget("sasjs"..i.."data")''; ';
498
- put ' put '' if(s:sub(1,7) == "%nrstr(")''; ';
499
- put ' put '' then''; ';
500
- put ' put '' sasdata=s:sub(8,s:len()-1)''; ';
501
- put ' put '' else''; ';
502
- put ' put '' sasdata=s''; ';
503
- put ' put '' end''; ';
504
- put ' put '' else''; ';
505
- put ' put '' for d = 1, sas.symget("sasjs"..i.."data0")''; ';
506
- put ' put '' do''; ';
507
- put ' put '' s=sas.symget("sasjs"..i.."data"..d)''; ';
508
- put ' put '' if(s:sub(1,7) == "%nrstr(")''; ';
509
- put ' put '' then''; ';
510
- put ' put '' sasdata=sasdata..s:sub(8,s:len()-1)''; ';
511
- put ' put '' else''; ';
512
- put ' put '' sasdata=sasdata..s''; ';
513
- put ' put '' end''; ';
514
- put ' put '' end''; ';
515
- put ' put '' end''; ';
516
- put ' put '' file = io.open(sas.pathname("work").."/"..tab..".csv", "a")''; ';
517
- put ' put '' io.output(file)''; ';
518
- put ' put '' io.write(sasdata)''; ';
519
- put ' put '' io.close(file)''; ';
520
- put ' put ''end''; ';
521
- put ' run; ';
522
- put ' %inc _sasjs; ';
479
+ put ' %if %length(&sasjs_tables.X)>1 %then %do; ';
523
480
  put ' ';
524
- put ' /* now read in the data */ ';
481
+ put ' /* convert data from macro variables to datasets */ ';
525
482
  put ' %do i=1 %to %sysfunc(countw(&sasjs_tables)); ';
526
- put ' %local table; %let table=%scan(&sasjs_tables,&i); ';
483
+ put ' %let table=%scan(&sasjs_tables,&i,%str( )); ';
484
+ put ' %if %symexist(sasjs&i.data0)=0 %then %let sasjs&i.data0=1; ';
485
+ put ' data _null_; ';
486
+ put ' file "%sysfunc(pathname(work))/&table..csv" recfm=n; ';
487
+ put ' retain nrflg 0; ';
488
+ put ' length line $32767; ';
489
+ put ' do i=1 to &&sasjs&i.data0; ';
490
+ put ' if &&sasjs&i.data0=1 then line=symget("sasjs&i.data"); ';
491
+ put ' else line=symget(cats("sasjs&i.data",i)); ';
492
+ put ' if i=1 and substr(line,1,7)=''%nrstr('' then do; ';
493
+ put ' nrflg=1; ';
494
+ put ' line=substr(line,8); ';
495
+ put ' end; ';
496
+ put ' if i=&&sasjs&i.data0 and nrflg=1 then do; ';
497
+ put ' line=substr(line,1,length(line)-1); ';
498
+ put ' end; ';
499
+ put ' put line +(-1) @; ';
500
+ put ' end; ';
501
+ put ' run; ';
527
502
  put ' data _null_; ';
528
503
  put ' infile "%sysfunc(pathname(work))/&table..csv" termstr=crlf ; ';
529
504
  put ' input; ';
530
505
  put ' if _n_=1 then call symputx(''input_statement'',_infile_); ';
531
506
  put ' list; ';
532
- put ' data &table; ';
507
+ put ' data work.&table; ';
533
508
  put ' infile "%sysfunc(pathname(work))/&table..csv" firstobs=2 dsd ';
534
509
  put ' termstr=crlf; ';
535
510
  put ' input &input_statement; ';
@@ -49,7 +49,7 @@
49
49
  sasjs_tables SYS_JES_JOB_URI;
50
50
  %if %index("&_debug",log) %then %let _debug=131;
51
51
 
52
- %local i tempds;
52
+ %local i tempds table;
53
53
  %let action=%upcase(&action);
54
54
 
55
55
  %if &action=FETCH %then %do;
@@ -64,60 +64,35 @@
64
64
  %end;
65
65
 
66
66
  /* if the sasjs_tables param is passed, we expect param based upload */
67
- %if %length(&sasjs_tables.XX)>2 %then %do;
68
- filename _sasjs "%sysfunc(pathname(work))/sasjs.lua";
69
- data _null_;
70
- file _sasjs;
71
- put 's=sas.symget("sasjs_tables")';
72
- put 'if(s:sub(1,7) == "%nrstr(")';
73
- put 'then';
74
- put ' tablist=s:sub(8,s:len()-1)';
75
- put 'else';
76
- put ' tablist=s';
77
- put 'end';
78
- put 'for i = 1,sas.countw(tablist) ';
79
- put 'do ';
80
- put ' tab=sas.scan(tablist,i)';
81
- put ' sasdata=""';
82
- put ' if (sas.symexist("sasjs"..i.."data0")==0)';
83
- put ' then';
84
- /* TODO - condense this logic */
85
- put ' s=sas.symget("sasjs"..i.."data")';
86
- put ' if(s:sub(1,7) == "%nrstr(")';
87
- put ' then';
88
- put ' sasdata=s:sub(8,s:len()-1)';
89
- put ' else';
90
- put ' sasdata=s';
91
- put ' end';
92
- put ' else';
93
- put ' for d = 1, sas.symget("sasjs"..i.."data0")';
94
- put ' do';
95
- put ' s=sas.symget("sasjs"..i.."data"..d)';
96
- put ' if(s:sub(1,7) == "%nrstr(")';
97
- put ' then';
98
- put ' sasdata=sasdata..s:sub(8,s:len()-1)';
99
- put ' else';
100
- put ' sasdata=sasdata..s';
101
- put ' end';
102
- put ' end';
103
- put ' end';
104
- put ' file = io.open(sas.pathname("work").."/"..tab..".csv", "a")';
105
- put ' io.output(file)';
106
- put ' io.write(sasdata)';
107
- put ' io.close(file)';
108
- put 'end';
109
- run;
110
- %inc _sasjs;
67
+ %if %length(&sasjs_tables.X)>1 %then %do;
111
68
 
112
- /* now read in the data */
69
+ /* convert data from macro variables to datasets */
113
70
  %do i=1 %to %sysfunc(countw(&sasjs_tables));
114
- %local table; %let table=%scan(&sasjs_tables,&i);
71
+ %let table=%scan(&sasjs_tables,&i,%str( ));
72
+ %if %symexist(sasjs&i.data0)=0 %then %let sasjs&i.data0=1;
73
+ data _null_;
74
+ file "%sysfunc(pathname(work))/&table..csv" recfm=n;
75
+ retain nrflg 0;
76
+ length line $32767;
77
+ do i=1 to &&sasjs&i.data0;
78
+ if &&sasjs&i.data0=1 then line=symget("sasjs&i.data");
79
+ else line=symget(cats("sasjs&i.data",i));
80
+ if i=1 and substr(line,1,7)='%nrstr(' then do;
81
+ nrflg=1;
82
+ line=substr(line,8);
83
+ end;
84
+ if i=&&sasjs&i.data0 and nrflg=1 then do;
85
+ line=substr(line,1,length(line)-1);
86
+ end;
87
+ put line +(-1) @;
88
+ end;
89
+ run;
115
90
  data _null_;
116
91
  infile "%sysfunc(pathname(work))/&table..csv" termstr=crlf ;
117
92
  input;
118
93
  if _n_=1 then call symputx('input_statement',_infile_);
119
94
  list;
120
- data &table;
95
+ data work.&table;
121
96
  infile "%sysfunc(pathname(work))/&table..csv" firstobs=2 dsd
122
97
  termstr=crlf;
123
98
  input &input_statement;