From 7c4278c3f974a6d487c6dded50aa10332952f415 Mon Sep 17 00:00:00 2001 From: munja Date: Thu, 23 Dec 2021 19:29:54 +0000 Subject: [PATCH] chore: updating all.sas --- all.sas | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/all.sas b/all.sas index 3d0629e..dc736a6 100644 --- a/all.sas +++ b/all.sas @@ -249,8 +249,12 @@ https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionex %put %mf_existvar(work.someds, somevar) - @param libds (positional) - 2 part dataset or view reference - @param var (positional) - variable name + @param [in] libds 2 part dataset or view reference + @param [in] var variable name + +

Related Macros

+ @li mf_existvar.test.sas + @version 9.2 @author Allan Bowe **/ @@ -1954,6 +1958,72 @@ Usage: %mend mf_wordsInStr1ButNotStr2; /** + @file + @brief Creates a text file using pure macro + @details Creates a text file of up to 10 lines. If further lines are + desired, feel free to [create an issue]( + https://github.com/sasjs/core/issues/new), or make a pull request! + + The use of PARMBUFF was considered for this macro, but it would have made + things problematic for writing lines containing commas. + + Usage: + + %mf_writefile(&sasjswork/myfile.txt,l1=some content,l2=more content) + data _null_; + infile "&sasjswork/myfile.txt"; + input; + list; + run; + + @param [in] fpath Full path to file to be created or appended to + @param [in] mode= (O) Available options are A or O as follows: + @li A APPEND mode, writes new records after the current end of the file. + @li O OUTPUT mode, writes new records from the beginning of the file. + @param [in] l1= First line + @param [in] l2= Second line (etc through to l10) + +

Related Macros

+ @li mf_writefile.test.sas + + @version 9.2 + @author Allan Bowe +**/ +/** @cond */ + +%macro mf_writefile(fpath,mode=O,l1=,l2=,l3=,l4=,l5=,l6=,l7=,l8=,l9=,l10= +)/*/STORE SOURCE*/; +%local fref rc fid i total_lines; + +/* find number of lines by reference to first non-blank param */ +%do i=10 %to 1 %by -1; + %if %str(&&l&i) ne %str() %then %goto continue; +%end; +%continue: +%let total_lines=&i; + +%if %sysfunc(filename(fref,&fpath)) ne 0 %then %do; + %put &=fref &=fpath; + %put %str(ERR)OR: %sysfunc(sysmsg()); + %return; +%end; + +%let fid=%sysfunc(fopen(&fref,&mode)); + +%if &fid=0 %then %do; + %put %str(ERR)OR: %sysfunc(sysmsg()); + %return; +%end; + +%do i=1 %to &total_lines; + %let rc=%sysfunc(fput(&fid, &&l&i)); + %let rc=%sysfunc(fwrite(&fid)); +%end; +%let rc=%sysfunc(fclose(&fid)); +%let rc=%sysfunc(filename(&fref)); + +%mend mf_writefile; +/** @endcond *//** @file @brief abort gracefully according to context @details Configures an abort mechanism according to site specific policies or @@ -7943,6 +8013,7 @@ data &ds2; %end; output; end; + stop; run; proc sort data=&ds2 nodupkey; by &pk_fields;