mirror of
https://github.com/sasjs/core.git
synced 2025-12-10 14:04:36 +00:00
fix: all the fixings
This commit is contained in:
@@ -89,7 +89,12 @@
|
||||
or "&SYSPROCESSNAME "="Compute Server "
|
||||
or &mode=INCLUDE
|
||||
%then %do;
|
||||
options obs=max replace nosyntaxcheck mprint;
|
||||
options obs=max replace mprint;
|
||||
%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5"
|
||||
%then %do;
|
||||
options nosyntaxcheck;
|
||||
%end;
|
||||
|
||||
%if &mode=INCLUDE %then %do;
|
||||
%if %sysfunc(exist(&errds))=1 %then %do;
|
||||
data _null_;
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<h4> SAS Macros </h4>
|
||||
@li mcf_length.sas
|
||||
@li mf_getuniquename.sas
|
||||
@li mf_getvarcount.sas
|
||||
@li mf_getvarlist.sas
|
||||
@li mf_getvartype.sas
|
||||
@li mf_getvarformat.sas
|
||||
@@ -60,7 +61,7 @@
|
||||
,outds=work.mp_getmaxvarlengths
|
||||
)/*/STORE SOURCE*/;
|
||||
|
||||
%local vars prefix x var fmt;
|
||||
%local vars prefix x var fmt srcds;
|
||||
%let vars=%mf_getvarlist(libds=&libds);
|
||||
%let prefix=%substr(%mf_getuniquename(),1,25);
|
||||
%let num2char=%upcase(&num2char);
|
||||
@@ -70,6 +71,24 @@
|
||||
%mcf_length(wrap=YES, insert_cmplib=YES)
|
||||
%end;
|
||||
|
||||
%if &num2char=NO
|
||||
and ("%substr(&sysver,1,1)"="4" or "%substr(&sysver,1,1)"="5")
|
||||
and %mf_getvarcount(&libds,typefilter=N) gt 0
|
||||
%then %do;
|
||||
/* custom functions not supported in summary operations */
|
||||
%let srcds=%mf_getuniquename();
|
||||
data &srcds/view=&srcds;
|
||||
set &libds;
|
||||
%do x=1 %to %sysfunc(countw(&vars,%str( )));
|
||||
%let var=%scan(&vars,&x);
|
||||
%if %mf_getvartype(&libds,&var)=N %then %do;
|
||||
&prefix.&x=mcf_length(&var);
|
||||
%end;
|
||||
%end;
|
||||
run;
|
||||
%end;
|
||||
%else %let srcds=&libds;
|
||||
|
||||
proc sql;
|
||||
create table &outds (rename=(
|
||||
%do x=1 %to %sysfunc(countw(&vars,%str( )));
|
||||
@@ -94,10 +113,15 @@ create table &outds (rename=(
|
||||
%end;
|
||||
%end;
|
||||
%else %do;
|
||||
max(mcf_length(&var)) as &prefix.&x
|
||||
%if "%substr(&sysver,1,1)"="4" or "%substr(&sysver,1,1)"="5" %then %do;
|
||||
max(&prefix.&x) as &prefix.&x
|
||||
%end;
|
||||
%else %do;
|
||||
max(mcf_length(&var)) as &prefix.&x
|
||||
%end;
|
||||
%end;
|
||||
%end;
|
||||
from &libds;
|
||||
from &srcds;
|
||||
|
||||
proc transpose data=&outds
|
||||
out=&outds(rename=(_name_=NAME COL1=MAXLEN));
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
data &ds1;
|
||||
set &dslist indsname=&inds_auto;
|
||||
&hashkey=put(md5(catx('|',%mf_getquotedstr(&key,quote=N))),$hex32.);
|
||||
&inds_keep=&inds_auto;
|
||||
&inds_keep=upcase(&inds_auto);
|
||||
proc sort;
|
||||
by &inds_keep &hashkey;
|
||||
run;
|
||||
@@ -160,8 +160,8 @@ data &ds4;
|
||||
tgtvar_nm=upcase(tgtvar_nm);
|
||||
if tgtvar_nm in (%upcase(&vlist));
|
||||
|
||||
if &inds_auto="&ds2" then tgtvar_type='N';
|
||||
else if &inds_auto="&ds3" then tgtvar_type='C';
|
||||
if upcase(&inds_auto)="&ds2" then tgtvar_type='N';
|
||||
else if upcase(&inds_auto)="&ds3" then tgtvar_type='C';
|
||||
else do;
|
||||
putlog "%str(ERR)OR: unidentified vartype input!" &inds_auto;
|
||||
call symputx('syscc',98);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li mf_getvarcount.sas
|
||||
@li mp_assertscope.sas
|
||||
|
||||
**/
|
||||
|
||||
@@ -13,6 +14,10 @@ data work.all work.nums(keep=num1 num2) work.chars(keep=char1 char2);
|
||||
output;
|
||||
run;
|
||||
|
||||
%mp_assertscope(SNAPSHOT)
|
||||
%put scope check:%mf_getvarcount(work.all);
|
||||
%mp_assertscope(COMPARE)
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(%mf_getvarcount(work.all)=5),
|
||||
desc=%str(Checking for mixed vars),
|
||||
|
||||
@@ -10,10 +10,48 @@
|
||||
|
||||
**/
|
||||
|
||||
data work.class ;
|
||||
attrib
|
||||
Name length= $8
|
||||
Sex length= $1
|
||||
Age length= 8
|
||||
Height length= 8
|
||||
Weight length= 8
|
||||
;
|
||||
infile cards dsd;
|
||||
input
|
||||
Name :$char.
|
||||
Sex :$char.
|
||||
Age
|
||||
Height
|
||||
Weight
|
||||
;
|
||||
datalines4;
|
||||
Alfred,M,14,69,112.5
|
||||
Alice,F,13,56.5,84
|
||||
Barbara,F,13,65.3,98
|
||||
Carol,F,14,62.8,102.5
|
||||
Henry,M,14,63.5,102.5
|
||||
James,M,12,57.3,83
|
||||
Jane,F,12,59.8,84.5
|
||||
Janet,F,15,62.5,112.5
|
||||
Jeffrey,M,13,62.5,84
|
||||
John,M,12,59,99.5
|
||||
Joyce,F,11,51.3,50.5
|
||||
Judy,F,14,64.3,90
|
||||
Louise,F,12,56.3,77
|
||||
Mary,F,15,66.5,112
|
||||
Philip,M,16,72,150
|
||||
Robert,M,12,64.8,128
|
||||
Ronald,M,15,67,133
|
||||
Thomas,M,11,57.5,85
|
||||
William,M,15,66.5,112
|
||||
;;;;
|
||||
run;
|
||||
|
||||
/* regular usage */
|
||||
%mp_assertscope(SNAPSHOT)
|
||||
%mp_getmaxvarlengths(sashelp.class,outds=work.myds)
|
||||
%mp_getmaxvarlengths(work.class,outds=work.myds)
|
||||
%mp_assertscope(COMPARE,desc=checking scope leakage on mp_getmaxvarlengths)
|
||||
%mp_assert(
|
||||
iftrue=(&syscc=0),
|
||||
|
||||
Reference in New Issue
Block a user