mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 23:50:06 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| abccafab7b | |||
| f6cec012da | |||
| d51be73017 | |||
| cafffbb509 | |||
| a88efacfab | |||
| cc7cc55022 | |||
| 15687be5d6 |
178
all.sas
178
all.sas
@@ -399,7 +399,7 @@ options noquotelenmax;
|
|||||||
@version 9.2
|
@version 9.2
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
**/ /** \cond */
|
**/
|
||||||
|
|
||||||
%macro mf_getengine(libref
|
%macro mf_getengine(libref
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
@@ -419,9 +419,7 @@ options noquotelenmax;
|
|||||||
|
|
||||||
&engine
|
&engine
|
||||||
|
|
||||||
%mend;
|
%mend;/**
|
||||||
|
|
||||||
/** \endcond *//**
|
|
||||||
@file
|
@file
|
||||||
@brief Returns the size of a file in bytes.
|
@brief Returns the size of a file in bytes.
|
||||||
@details Provide full path/filename.extension to the file, eg:
|
@details Provide full path/filename.extension to the file, eg:
|
||||||
@@ -1904,6 +1902,149 @@ Usage:
|
|||||||
|
|
||||||
%mend;
|
%mend;
|
||||||
/**
|
/**
|
||||||
|
@file mp_csv2ds.sas
|
||||||
|
@brief Efficient import of arbitrary CSV using a dataset as template
|
||||||
|
@details Used to import relevant columns from a large CSV using
|
||||||
|
a dataset to provide the types and lengths. Assumes that a header
|
||||||
|
row is provided, and datarows start on line 2. Extra columns in
|
||||||
|
both the CSV and base dataset are ignored.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
filename mycsv temp;
|
||||||
|
data _null_;
|
||||||
|
file mycsv;
|
||||||
|
put 'name,age,nickname';
|
||||||
|
put 'John,48,Jonny';
|
||||||
|
put 'Jennifer,23,Jen';
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_csv2ds(inref=mycsv,outds=myds,baseds=sashelp.class)
|
||||||
|
|
||||||
|
|
||||||
|
@param inref= fileref to the CSV
|
||||||
|
@param outds= output ds (lib.ds format)
|
||||||
|
@param view= Set to YES or NO to determine whether the output should be
|
||||||
|
a view or not. Default is NO (not a view).
|
||||||
|
@param baseds= Template dataset on which to create the input statement.
|
||||||
|
Is used to determine types, lengths, and any informats.
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
|
<h4> Dependencies </h4>
|
||||||
|
@li mp_abort.sas
|
||||||
|
@li mf_existds.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_csv2ds(inref=0,outds=0,baseds=0,view=NO);
|
||||||
|
|
||||||
|
%mp_abort(iftrue=( &inref=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the INREF variable must be provided)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue=( %superq(outds)=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the OUTDS variable must be provided)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue=( &baseds=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the BASEDS variable must be provided)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue=( &baseds=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the BASEDS variable must be provided)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue=( %mf_existds(&baseds)=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the BASEDS dataset (&baseds) needs to be assigned, and to exist)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* count rows */
|
||||||
|
%local hasheader; %let hasheader=0;
|
||||||
|
data _null_;
|
||||||
|
if _N_ > 1 then do;
|
||||||
|
call symputx('hasheader',1,'l');
|
||||||
|
stop;
|
||||||
|
end;
|
||||||
|
infile &inref;
|
||||||
|
input;
|
||||||
|
run;
|
||||||
|
%mp_abort(iftrue=( &hasheader=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(No header row in &inref)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* get the variables in the CSV */
|
||||||
|
data _data_;
|
||||||
|
infile &inref;
|
||||||
|
input;
|
||||||
|
length name $32;
|
||||||
|
do i=1 to countc(_infile_,',')+1;
|
||||||
|
name=upcase(scan(_infile_,i,','));
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
%local csv_vars;%let csv_vars=&syslast;
|
||||||
|
|
||||||
|
/* get the variables in the dataset */
|
||||||
|
proc contents noprint data=&baseds
|
||||||
|
out=_data_ (keep=name type length format: informat);
|
||||||
|
run;
|
||||||
|
%local base_vars; %let base_vars=&syslast;
|
||||||
|
|
||||||
|
proc sql undo_policy=none;
|
||||||
|
create table &csv_vars as
|
||||||
|
select a.*
|
||||||
|
,b.type
|
||||||
|
,b.length
|
||||||
|
,b.format
|
||||||
|
,b.formatd
|
||||||
|
,b.formatl
|
||||||
|
,b.informat
|
||||||
|
from &csv_vars a
|
||||||
|
left join &base_vars b
|
||||||
|
on a.name=upcase(b.name)
|
||||||
|
order by i;
|
||||||
|
|
||||||
|
/* prepare the input statement */
|
||||||
|
%local instat dropvars;
|
||||||
|
data _null_;
|
||||||
|
set &syslast end=last;
|
||||||
|
length in dropvars $32767;
|
||||||
|
retain in dropvars;
|
||||||
|
if missing(type) then do;
|
||||||
|
informat='$1.';
|
||||||
|
dropvars=catx(' ',dropvars,name);
|
||||||
|
end;
|
||||||
|
else if missing(informat) then do;
|
||||||
|
if type=1 then informat='best.';
|
||||||
|
else informat=cats('$',length,'.');
|
||||||
|
end;
|
||||||
|
else informat=cats(informat,'.');
|
||||||
|
in=catx(' ',in,name,':',informat);
|
||||||
|
if last then do;
|
||||||
|
call symputx('instat',in,'l');
|
||||||
|
call symputx('dropvars',dropvars,'l');
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* import the CSV */
|
||||||
|
data &outds
|
||||||
|
%if %upcase(&view)=YES %then %do;
|
||||||
|
/view=&outds
|
||||||
|
%end;
|
||||||
|
;
|
||||||
|
infile &inref dsd firstobs=2;
|
||||||
|
input &instat;
|
||||||
|
%if %length(&dropvars)>0 %then %do;
|
||||||
|
drop &dropvars;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mend;/**
|
||||||
@file mp_deleteconstraints.sas
|
@file mp_deleteconstraints.sas
|
||||||
@brief Delete constraionts
|
@brief Delete constraionts
|
||||||
@details Takes the output from mp_getconstraints.sas as input
|
@details Takes the output from mp_getconstraints.sas as input
|
||||||
@@ -2642,7 +2783,7 @@ run;
|
|||||||
%let curds=%scan(&dsnlist,&x);
|
%let curds=%scan(&dsnlist,&x);
|
||||||
data _null_;
|
data _null_;
|
||||||
file &fref mod;
|
file &fref mod;
|
||||||
length nm lab $1024;
|
length nm lab $1024 typ $20;
|
||||||
set &colinfo (where=(upcase(memname)="&curds")) end=last;
|
set &colinfo (where=(upcase(memname)="&curds")) end=last;
|
||||||
|
|
||||||
if _n_=1 then do;
|
if _n_=1 then do;
|
||||||
@@ -2656,10 +2797,12 @@ run;
|
|||||||
end;
|
end;
|
||||||
else put " ,"@@;
|
else put " ,"@@;
|
||||||
if length(format)>1 then fmt=" format="!!cats(format);
|
if length(format)>1 then fmt=" format="!!cats(format);
|
||||||
len=" length="!!cats(length);
|
if length(label)>1 then lab=" label="!!quote(trim(label));
|
||||||
lab=" label="!!quote(trim(label));
|
|
||||||
if notnull='yes' then notnul=' not null';
|
if notnull='yes' then notnul=' not null';
|
||||||
put name type len fmt notnul lab;
|
if type='char' then typ=cats('char(',length,')');
|
||||||
|
else if length ne 8 then typ='num length='!!left(length);
|
||||||
|
else typ='num';
|
||||||
|
put name typ fmt notnul lab;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* Extra step for data constraints */
|
/* Extra step for data constraints */
|
||||||
@@ -3968,7 +4111,7 @@ proc sql
|
|||||||
|
|
||||||
options &etls_syntaxcheck;
|
options &etls_syntaxcheck;
|
||||||
%mend;/**
|
%mend;/**
|
||||||
@file mp_streamfile.sas
|
@file
|
||||||
@brief Streams a file to _webout according to content type
|
@brief Streams a file to _webout according to content type
|
||||||
@details Will set headers using appropriate functions (SAS 9 vs Viya) and send
|
@details Will set headers using appropriate functions (SAS 9 vs Viya) and send
|
||||||
content as a binary stream.
|
content as a binary stream.
|
||||||
@@ -3986,6 +4129,7 @@ proc sql
|
|||||||
|
|
||||||
@param contenttype= Either TEXT, ZIP, CSV, EXCEL (default TEXT)
|
@param contenttype= Either TEXT, ZIP, CSV, EXCEL (default TEXT)
|
||||||
@param inloc= /path/to/file.ext to be sent
|
@param inloc= /path/to/file.ext to be sent
|
||||||
|
@param inref= fileref of file to be sent (if provided, overrides `inloc`)
|
||||||
@param outname= the name of the file, as downloaded by the browser
|
@param outname= the name of the file, as downloaded by the browser
|
||||||
|
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -3996,6 +4140,7 @@ proc sql
|
|||||||
%macro mp_streamfile(
|
%macro mp_streamfile(
|
||||||
contenttype=TEXT
|
contenttype=TEXT
|
||||||
,inloc=
|
,inloc=
|
||||||
|
,inref=0
|
||||||
,outname=
|
,outname=
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
@@ -4011,7 +4156,7 @@ proc sql
|
|||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
||||||
contenttype='application/zip'
|
contenttype='application/zip'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
@@ -4025,7 +4170,7 @@ proc sql
|
|||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
||||||
contenttype='application/vnd.ms-excel'
|
contenttype='application/vnd.ms-excel'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
@@ -4038,7 +4183,7 @@ proc sql
|
|||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
||||||
contenttype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
contenttype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
@@ -4071,7 +4216,7 @@ proc sql
|
|||||||
%else %if &contentype=HTML %then %do;
|
%else %if &contentype=HTML %then %do;
|
||||||
%if &platform=SASVIYA %then %do;
|
%if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
||||||
contenttype="text/html";
|
contenttype="text/html";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
@@ -4079,7 +4224,12 @@ proc sql
|
|||||||
%return;
|
%return;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mp_binarycopy(inloc="&inloc",outref=_webout)
|
%if &inref ne 0 %then %do;
|
||||||
|
%mp_binarycopy(inref=&inref,outref=_webout)
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
%mp_binarycopy(inloc="&inloc",outref=_webout)
|
||||||
|
%end;
|
||||||
|
|
||||||
%mend;/**
|
%mend;/**
|
||||||
@file mp_unzip.sas
|
@file mp_unzip.sas
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
@version 9.2
|
@version 9.2
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|
||||||
**/ /** \cond */
|
**/
|
||||||
|
|
||||||
%macro mf_getengine(libref
|
%macro mf_getengine(libref
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
@@ -42,6 +42,4 @@
|
|||||||
|
|
||||||
&engine
|
&engine
|
||||||
|
|
||||||
%mend;
|
%mend;
|
||||||
|
|
||||||
/** \endcond */
|
|
||||||
144
base/mp_csv2ds.sas
Normal file
144
base/mp_csv2ds.sas
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
/**
|
||||||
|
@file mp_csv2ds.sas
|
||||||
|
@brief Efficient import of arbitrary CSV using a dataset as template
|
||||||
|
@details Used to import relevant columns from a large CSV using
|
||||||
|
a dataset to provide the types and lengths. Assumes that a header
|
||||||
|
row is provided, and datarows start on line 2. Extra columns in
|
||||||
|
both the CSV and base dataset are ignored.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
filename mycsv temp;
|
||||||
|
data _null_;
|
||||||
|
file mycsv;
|
||||||
|
put 'name,age,nickname';
|
||||||
|
put 'John,48,Jonny';
|
||||||
|
put 'Jennifer,23,Jen';
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_csv2ds(inref=mycsv,outds=myds,baseds=sashelp.class)
|
||||||
|
|
||||||
|
|
||||||
|
@param inref= fileref to the CSV
|
||||||
|
@param outds= output ds (lib.ds format)
|
||||||
|
@param view= Set to YES or NO to determine whether the output should be
|
||||||
|
a view or not. Default is NO (not a view).
|
||||||
|
@param baseds= Template dataset on which to create the input statement.
|
||||||
|
Is used to determine types, lengths, and any informats.
|
||||||
|
|
||||||
|
@version 9.2
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
|
<h4> Dependencies </h4>
|
||||||
|
@li mp_abort.sas
|
||||||
|
@li mf_existds.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_csv2ds(inref=0,outds=0,baseds=0,view=NO);
|
||||||
|
|
||||||
|
%mp_abort(iftrue=( &inref=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the INREF variable must be provided)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue=( %superq(outds)=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the OUTDS variable must be provided)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue=( &baseds=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the BASEDS variable must be provided)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue=( &baseds=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the BASEDS variable must be provided)
|
||||||
|
)
|
||||||
|
%mp_abort(iftrue=( %mf_existds(&baseds)=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(the BASEDS dataset (&baseds) needs to be assigned, and to exist)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* count rows */
|
||||||
|
%local hasheader; %let hasheader=0;
|
||||||
|
data _null_;
|
||||||
|
if _N_ > 1 then do;
|
||||||
|
call symputx('hasheader',1,'l');
|
||||||
|
stop;
|
||||||
|
end;
|
||||||
|
infile &inref;
|
||||||
|
input;
|
||||||
|
run;
|
||||||
|
%mp_abort(iftrue=( &hasheader=0 )
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(No header row in &inref)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* get the variables in the CSV */
|
||||||
|
data _data_;
|
||||||
|
infile &inref;
|
||||||
|
input;
|
||||||
|
length name $32;
|
||||||
|
do i=1 to countc(_infile_,',')+1;
|
||||||
|
name=upcase(scan(_infile_,i,','));
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
%local csv_vars;%let csv_vars=&syslast;
|
||||||
|
|
||||||
|
/* get the variables in the dataset */
|
||||||
|
proc contents noprint data=&baseds
|
||||||
|
out=_data_ (keep=name type length format: informat);
|
||||||
|
run;
|
||||||
|
%local base_vars; %let base_vars=&syslast;
|
||||||
|
|
||||||
|
proc sql undo_policy=none;
|
||||||
|
create table &csv_vars as
|
||||||
|
select a.*
|
||||||
|
,b.type
|
||||||
|
,b.length
|
||||||
|
,b.format
|
||||||
|
,b.formatd
|
||||||
|
,b.formatl
|
||||||
|
,b.informat
|
||||||
|
from &csv_vars a
|
||||||
|
left join &base_vars b
|
||||||
|
on a.name=upcase(b.name)
|
||||||
|
order by i;
|
||||||
|
|
||||||
|
/* prepare the input statement */
|
||||||
|
%local instat dropvars;
|
||||||
|
data _null_;
|
||||||
|
set &syslast end=last;
|
||||||
|
length in dropvars $32767;
|
||||||
|
retain in dropvars;
|
||||||
|
if missing(type) then do;
|
||||||
|
informat='$1.';
|
||||||
|
dropvars=catx(' ',dropvars,name);
|
||||||
|
end;
|
||||||
|
else if missing(informat) then do;
|
||||||
|
if type=1 then informat='best.';
|
||||||
|
else informat=cats('$',length,'.');
|
||||||
|
end;
|
||||||
|
else informat=cats(informat,'.');
|
||||||
|
in=catx(' ',in,name,':',informat);
|
||||||
|
if last then do;
|
||||||
|
call symputx('instat',in,'l');
|
||||||
|
call symputx('dropvars',dropvars,'l');
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* import the CSV */
|
||||||
|
data &outds
|
||||||
|
%if %upcase(&view)=YES %then %do;
|
||||||
|
/view=&outds
|
||||||
|
%end;
|
||||||
|
;
|
||||||
|
infile &inref dsd firstobs=2;
|
||||||
|
input &instat;
|
||||||
|
%if %length(&dropvars)>0 %then %do;
|
||||||
|
drop &dropvars;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mend;
|
||||||
@@ -131,7 +131,7 @@ run;
|
|||||||
%let curds=%scan(&dsnlist,&x);
|
%let curds=%scan(&dsnlist,&x);
|
||||||
data _null_;
|
data _null_;
|
||||||
file &fref mod;
|
file &fref mod;
|
||||||
length nm lab $1024;
|
length nm lab $1024 typ $20;
|
||||||
set &colinfo (where=(upcase(memname)="&curds")) end=last;
|
set &colinfo (where=(upcase(memname)="&curds")) end=last;
|
||||||
|
|
||||||
if _n_=1 then do;
|
if _n_=1 then do;
|
||||||
@@ -145,10 +145,12 @@ run;
|
|||||||
end;
|
end;
|
||||||
else put " ,"@@;
|
else put " ,"@@;
|
||||||
if length(format)>1 then fmt=" format="!!cats(format);
|
if length(format)>1 then fmt=" format="!!cats(format);
|
||||||
len=" length="!!cats(length);
|
if length(label)>1 then lab=" label="!!quote(trim(label));
|
||||||
lab=" label="!!quote(trim(label));
|
|
||||||
if notnull='yes' then notnul=' not null';
|
if notnull='yes' then notnul=' not null';
|
||||||
put name type len fmt notnul lab;
|
if type='char' then typ=cats('char(',length,')');
|
||||||
|
else if length ne 8 then typ='num length='!!left(length);
|
||||||
|
else typ='num';
|
||||||
|
put name typ fmt notnul lab;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* Extra step for data constraints */
|
/* Extra step for data constraints */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
@file mp_streamfile.sas
|
@file
|
||||||
@brief Streams a file to _webout according to content type
|
@brief Streams a file to _webout according to content type
|
||||||
@details Will set headers using appropriate functions (SAS 9 vs Viya) and send
|
@details Will set headers using appropriate functions (SAS 9 vs Viya) and send
|
||||||
content as a binary stream.
|
content as a binary stream.
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
@param contenttype= Either TEXT, ZIP, CSV, EXCEL (default TEXT)
|
@param contenttype= Either TEXT, ZIP, CSV, EXCEL (default TEXT)
|
||||||
@param inloc= /path/to/file.ext to be sent
|
@param inloc= /path/to/file.ext to be sent
|
||||||
|
@param inref= fileref of file to be sent (if provided, overrides `inloc`)
|
||||||
@param outname= the name of the file, as downloaded by the browser
|
@param outname= the name of the file, as downloaded by the browser
|
||||||
|
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
%macro mp_streamfile(
|
%macro mp_streamfile(
|
||||||
contenttype=TEXT
|
contenttype=TEXT
|
||||||
,inloc=
|
,inloc=
|
||||||
|
,inref=0
|
||||||
,outname=
|
,outname=
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@
|
|||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
||||||
contenttype='application/zip'
|
contenttype='application/zip'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
@@ -56,7 +58,7 @@
|
|||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
||||||
contenttype='application/vnd.ms-excel'
|
contenttype='application/vnd.ms-excel'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
@@ -69,7 +71,7 @@
|
|||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
||||||
contenttype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
contenttype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
@@ -102,7 +104,7 @@
|
|||||||
%else %if &contentype=HTML %then %do;
|
%else %if &contentype=HTML %then %do;
|
||||||
%if &platform=SASVIYA %then %do;
|
%if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
||||||
contenttype="text/html";
|
contenttype="text/html";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
@@ -110,6 +112,11 @@
|
|||||||
%return;
|
%return;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mp_binarycopy(inloc="&inloc",outref=_webout)
|
%if &inref ne 0 %then %do;
|
||||||
|
%mp_binarycopy(inref=&inref,outref=_webout)
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
%mp_binarycopy(inloc="&inloc",outref=_webout)
|
||||||
|
%end;
|
||||||
|
|
||||||
%mend;
|
%mend;
|
||||||
Reference in New Issue
Block a user