@sasjs/core 4.33.1 → 4.34.1

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- @file mp_cleancsv.sas
2
+ @file
3
3
  @brief Fixes embedded cr / lf / crlf in CSV
4
4
  @details CSVs will sometimes contain lf or crlf within quotes (eg when
5
5
  saved by excel). When the termstr is ALSO lf or crlf that can be tricky
@@ -7,14 +7,16 @@
7
7
  This macro converts any csv to follow the convention of a windows excel file,
8
8
  applying CRLF line endings and converting embedded cr and crlf to lf.
9
9
 
10
- usage:
10
+ Usage:
11
11
 
12
12
  fileref mycsv "/path/your/csv";
13
13
  %mp_cleancsv(in=mycsv,out=/path/new.csv)
14
14
 
15
- @param in= provide path or fileref to input csv
16
- @param out= output path or fileref to output csv
17
- @param qchar= quote char - hex code 22 is the double quote.
15
+ @param in= (NOTPROVIDED) Provide path or fileref to input csv. If a period is
16
+ found, it is assumed to be a file.
17
+ @param out= (NOTPROVIDED) Output path or fileref to output csv. If a period
18
+ is found, it is assumed to be a file.
19
+ @param qchar= ('22'x) Quote char - hex code 22 is the double quote.
18
20
 
19
21
  @version 9.2
20
22
  @author Allan Bowe
@@ -56,9 +58,14 @@
56
58
  else do;
57
59
  /* outside a quote, change cr and lf to crlf */
58
60
  if inchar='0D'x then do;
61
+ crblank:
59
62
  put '0D0A'x;
60
63
  input inchar $char1.;
61
- if inchar ne '0A'x then do;
64
+ if inchar='0D'x then do;
65
+ /* multiple CR indicates CR formatted file with blank lines */
66
+ goto crblank;
67
+ end;
68
+ else if inchar ne '0A'x then do;
62
69
  put inchar $char1.;
63
70
  if inchar=qchar then isq = mod(isq+1,2);
64
71
  end;
@@ -126,7 +126,6 @@
126
126
  if format='' then fmt=cats('$',length,'.');
127
127
  else if formatl=0 then fmt=cats(format,'.');
128
128
  else fmt=cats(format,formatl,'.');
129
- newlen=max(formatl,length);
130
129
  end;
131
130
  else do;
132
131
  typelong='num';
@@ -134,15 +133,12 @@
134
133
  else if formatl=0 then fmt=cats(format,'.');
135
134
  else if formatd=0 then fmt=cats(format,formatl,'.');
136
135
  else fmt=cats(format,formatl,'.',formatd);
137
- /* needs to be wide, for datetimes etc */
138
- newlen=max(length,formatl,24);
139
136
  end;
140
137
  /* 32 char unique name */
141
138
  newname='sasjs'!!substr(cats(put(md5(name),$hex32.)),1,27);
142
139
 
143
140
  call symputx(cats('name',_n_),name,'l');
144
141
  call symputx(cats('newname',_n_),newname,'l');
145
- call symputx(cats('len',_n_),newlen,'l');
146
142
  call symputx(cats('length',_n_),length,'l');
147
143
  call symputx(cats('fmt',_n_),fmt,'l');
148
144
  call symputx(cats('type',_n_),type,'l');
@@ -195,7 +191,8 @@
195
191
  %end;
196
192
  ));
197
193
  %do i=1 %to &numcols;
198
- length &&name&i $&&len&i;
194
+ /* formatted values can be up to length 32767 */
195
+ length &&name&i $32767;
199
196
  %if &&typelong&i=num %then %do;
200
197
  &&name&i=left(put(&&newname&i,&&fmt&i));
201
198
  %end;
@@ -149,7 +149,6 @@ data _null_;
149
149
  put ' if format='''' then fmt=cats(''$'',length,''.''); ';
150
150
  put ' else if formatl=0 then fmt=cats(format,''.''); ';
151
151
  put ' else fmt=cats(format,formatl,''.''); ';
152
- put ' newlen=max(formatl,length); ';
153
152
  put ' end; ';
154
153
  put ' else do; ';
155
154
  put ' typelong=''num''; ';
@@ -157,15 +156,12 @@ data _null_;
157
156
  put ' else if formatl=0 then fmt=cats(format,''.''); ';
158
157
  put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
159
158
  put ' else fmt=cats(format,formatl,''.'',formatd); ';
160
- put ' /* needs to be wide, for datetimes etc */ ';
161
- put ' newlen=max(length,formatl,24); ';
162
159
  put ' end; ';
163
160
  put ' /* 32 char unique name */ ';
164
161
  put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
165
162
  put ' ';
166
163
  put ' call symputx(cats(''name'',_n_),name,''l''); ';
167
164
  put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
168
- put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
169
165
  put ' call symputx(cats(''length'',_n_),length,''l''); ';
170
166
  put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
171
167
  put ' call symputx(cats(''type'',_n_),type,''l''); ';
@@ -218,7 +214,8 @@ data _null_;
218
214
  put ' %end; ';
219
215
  put ' )); ';
220
216
  put ' %do i=1 %to &numcols; ';
221
- put ' length &&name&i $&&len&i; ';
217
+ put ' /* formatted values can be up to length 32767 */ ';
218
+ put ' length &&name&i $32767; ';
222
219
  put ' %if &&typelong&i=num %then %do; ';
223
220
  put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
224
221
  put ' %end; ';
@@ -0,0 +1,50 @@
1
+ /**
2
+ @file
3
+ @brief Creates a metadata folder
4
+ @details Creates a metadata folder using the batch tools
5
+
6
+ Usage:
7
+
8
+ %mmx_createmetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
9
+
10
+ <h4> SAS Macros </h4>
11
+ @li mf_loc.sas
12
+ @li mp_abort.sas
13
+
14
+ @param loc= the metadata folder to delete
15
+ @param user= username
16
+ @param pass= password
17
+
18
+ @version 9.4
19
+ @author Allan Bowe
20
+
21
+ **/
22
+
23
+ %macro mmx_createmetafolder(loc=,user=,pass=);
24
+
25
+ %local host port path connx_string msg;
26
+ %let host=%sysfunc(getoption(metaserver));
27
+ %let port=%sysfunc(getoption(metaport));
28
+ %let path=%mf_loc(POF)/tools;
29
+
30
+ %let connx_string= -host &host -port &port -user '&user' -password '&pass';
31
+ /* remove directory */
32
+ data _null_;
33
+ infile " &path/sas-make-folder &connx_string ""&loc"" -makeFullPath 2>&1"
34
+ pipe lrecl=10000;
35
+ input;
36
+ putlog _infile_;
37
+ run;
38
+
39
+ data _null_; /* check tree exists */
40
+ length type uri $256;
41
+ rc=metadata_pathobj("","&loc","Folder",type,uri);
42
+ call symputx('foldertype',type,'l');
43
+ run;
44
+ %let msg=Location (&loc) was not created!!;
45
+ %mp_abort(iftrue= (&foldertype ne Tree)
46
+ ,mac=&_program..sas
47
+ ,msg=%superq(msg)
48
+ )
49
+
50
+ %mend mmx_createmetafolder;
@@ -7,7 +7,7 @@
7
7
 
8
8
  Usage:
9
9
 
10
- %mmx_deletemetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
10
+ %mmx_deletemetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
11
11
 
12
12
  <h4> SAS Macros </h4>
13
13
  @li mf_loc.sas
@@ -37,4 +37,4 @@ data _null_;
37
37
  putlog _infile_;
38
38
  run;
39
39
 
40
- %mend mmx_deletemetafolder;
40
+ %mend mmx_deletemetafolder;
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "3.13.0"
37
37
  },
38
- "version": "4.33.1"
38
+ "version": "4.34.1"
39
39
  }
@@ -150,7 +150,6 @@ data _null_;
150
150
  put ' if format='''' then fmt=cats(''$'',length,''.''); ';
151
151
  put ' else if formatl=0 then fmt=cats(format,''.''); ';
152
152
  put ' else fmt=cats(format,formatl,''.''); ';
153
- put ' newlen=max(formatl,length); ';
154
153
  put ' end; ';
155
154
  put ' else do; ';
156
155
  put ' typelong=''num''; ';
@@ -158,15 +157,12 @@ data _null_;
158
157
  put ' else if formatl=0 then fmt=cats(format,''.''); ';
159
158
  put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
160
159
  put ' else fmt=cats(format,formatl,''.'',formatd); ';
161
- put ' /* needs to be wide, for datetimes etc */ ';
162
- put ' newlen=max(length,formatl,24); ';
163
160
  put ' end; ';
164
161
  put ' /* 32 char unique name */ ';
165
162
  put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
166
163
  put ' ';
167
164
  put ' call symputx(cats(''name'',_n_),name,''l''); ';
168
165
  put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
169
- put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
170
166
  put ' call symputx(cats(''length'',_n_),length,''l''); ';
171
167
  put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
172
168
  put ' call symputx(cats(''type'',_n_),type,''l''); ';
@@ -219,7 +215,8 @@ data _null_;
219
215
  put ' %end; ';
220
216
  put ' )); ';
221
217
  put ' %do i=1 %to &numcols; ';
222
- put ' length &&name&i $&&len&i; ';
218
+ put ' /* formatted values can be up to length 32767 */ ';
219
+ put ' length &&name&i $32767; ';
223
220
  put ' %if &&typelong&i=num %then %do; ';
224
221
  put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
225
222
  put ' %end; ';
@@ -292,7 +292,6 @@ data _null_;
292
292
  put ' if format='''' then fmt=cats(''$'',length,''.''); ';
293
293
  put ' else if formatl=0 then fmt=cats(format,''.''); ';
294
294
  put ' else fmt=cats(format,formatl,''.''); ';
295
- put ' newlen=max(formatl,length); ';
296
295
  put ' end; ';
297
296
  put ' else do; ';
298
297
  put ' typelong=''num''; ';
@@ -300,15 +299,12 @@ data _null_;
300
299
  put ' else if formatl=0 then fmt=cats(format,''.''); ';
301
300
  put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
302
301
  put ' else fmt=cats(format,formatl,''.'',formatd); ';
303
- put ' /* needs to be wide, for datetimes etc */ ';
304
- put ' newlen=max(length,formatl,24); ';
305
302
  put ' end; ';
306
303
  put ' /* 32 char unique name */ ';
307
304
  put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
308
305
  put ' ';
309
306
  put ' call symputx(cats(''name'',_n_),name,''l''); ';
310
307
  put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
311
- put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
312
308
  put ' call symputx(cats(''length'',_n_),length,''l''); ';
313
309
  put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
314
310
  put ' call symputx(cats(''type'',_n_),type,''l''); ';
@@ -361,7 +357,8 @@ data _null_;
361
357
  put ' %end; ';
362
358
  put ' )); ';
363
359
  put ' %do i=1 %to &numcols; ';
364
- put ' length &&name&i $&&len&i; ';
360
+ put ' /* formatted values can be up to length 32767 */ ';
361
+ put ' length &&name&i $32767; ';
365
362
  put ' %if &&typelong&i=num %then %do; ';
366
363
  put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
367
364
  put ' %end; ';