From a88efacfabe071412e3f0fc5a61b5c33bb432620 Mon Sep 17 00:00:00 2001 From: Allan Bowe Date: Mon, 2 Nov 2020 17:15:29 +0100 Subject: [PATCH] fix: making view an option so that existence can be checked for --- all.sas | 18 +++++++++++++++--- base/mp_csv2ds.sas | 17 ++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/all.sas b/all.sas index 42e8b8b..5d91813 100644 --- a/all.sas +++ b/all.sas @@ -1925,7 +1925,9 @@ Usage: @param inref= fileref to the CSV - @param outds= output ds. Could also be a view (eg `outds=myds/view=myds`) + @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. @@ -1939,7 +1941,7 @@ Usage: %let syscc=4; %abort; %end; -%if &outds=0 %then %do; +%if %superq(outds)=0 %then %do; %put %str(ERR)OR: the OUTDS variable must be provided; %let syscc=4; %return; @@ -1949,6 +1951,11 @@ Usage: %let syscc=4; %return; %end; +%if %sysfunc(exist(&BASEDS)) ne 1 & %sysfunc(exist(&BASEDS,VIEW)) ne 1 %then %do; + %put %str(ERR)OR: the BASEDS dataset needs to be assigned, and to exist; + %let syscc=4; + %return; +%end; /* get the variables in the CSV */ data _data_; @@ -2004,7 +2011,12 @@ data _null_; end; run; -data &outds; +/* import the CSV */ +data &outds + %if %upcase(&view)=YES %then %do; + /view=&outds + %end; + ; infile &inref dsd firstobs=2; input &instat; drop &dropvars; diff --git a/base/mp_csv2ds.sas b/base/mp_csv2ds.sas index bbc4fdc..c0e42fe 100644 --- a/base/mp_csv2ds.sas +++ b/base/mp_csv2ds.sas @@ -20,7 +20,9 @@ @param inref= fileref to the CSV - @param outds= output ds. Could also be a view (eg `outds=myds/view=myds`) + @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. @@ -34,7 +36,7 @@ %let syscc=4; %abort; %end; -%if &outds=0 %then %do; +%if %superq(outds)=0 %then %do; %put %str(ERR)OR: the OUTDS variable must be provided; %let syscc=4; %return; @@ -44,6 +46,11 @@ %let syscc=4; %return; %end; +%if %sysfunc(exist(&BASEDS)) ne 1 & %sysfunc(exist(&BASEDS,VIEW)) ne 1 %then %do; + %put %str(ERR)OR: the BASEDS dataset needs to be assigned, and to exist; + %let syscc=4; + %return; +%end; /* get the variables in the CSV */ data _data_; @@ -100,7 +107,11 @@ data _null_; run; /* import the CSV */ -data &outds; +data &outds + %if %upcase(&view)=YES %then %do; + /view=&outds + %end; + ; infile &inref dsd firstobs=2; input &instat; drop &dropvars;