|
Macros for SAS Application Developers
https://github.com/sasjs/core |
Creates a file in SAS Drive using the API method. More...
Go to the source code of this file.
Creates a file in SAS Drive using the API interface. If the parent folder does not exist, it is created. The API approach is more flexible than using the filesrvc engine of the filename statement, as it provides more options.
SAS docs: https://developer.sas.com/rest-apis/files/createNewFile
Usage:
filename myfile temp; data _null_; file myfile; put 'something'; run; %mv_createfile(path=/Public/temp,name=newfile.txt,inref=myfile)
The macro also supports find & replace (used by the SASjs Streaming App build program). This allows one string to be replaced by another at the point at which the file is created. This is done by passing in the NAMES of the macro variables containing the values to be swapped, eg:
filename fref temp; data _null_; file fref; put 'whenever life gets you down, Mrs Brown..'; run; %let f=Mrs Brown; %let r=just remember that you're standing on a planet that's evolving; %mv_createfile(path=/Public,name=life.md,inref=fref,fin,swap=f r)
| [in] | path= | The parent (SAS Drive) folder in which to create the file |
| [in] | name= | The name of the file to be created |
| [in] | inref= | The fileref pointing to the file to be uploaded |
| [in] | intype= | (BINARY) The type of the input data. Valid values:
|
| [in] | contentdisp= | (attchment) Content Disposition. Example values:
|
| [in] | ctype= | (0) The actual MIME type of the file (if blank will be determined based on file extension)) |
| [in] | access_token_var= | The global macro variable to contain the access token, if using authorization_code grant type. |
| [in] | grant_type= | (sas_services) Valid values are:
|
| [in] | force= | (YES) Will overwrite (delete / recreate) files by default. Set to NO to abort if a file already exists in that location. |
| pin] | swap= (0) Provide two macro variable NAMES that contain the values to be swapped, eg swap=find replace (see also the example above) | |
| [out] | outds= | (null) Output dataset with the uri of the new file |
| [in] | mdebug= | (0) Set to 1 to enable DEBUG messages |
Definition in file mv_createfile.sas.