mirror of
https://github.com/sasjs/core.git
synced 2026-01-14 20:10:05 +00:00
fix: using byte codes to tidy up apostrophe logic, and new param for mf_getquotedstr macro
This commit is contained in:
21
all.sas
21
all.sas
@@ -626,12 +626,12 @@ https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionex
|
|||||||
for:
|
for:
|
||||||
> "these","words","are","double","quoted"
|
> "these","words","are","double","quoted"
|
||||||
|
|
||||||
@param in_str the unquoted, spaced delimited string to transform
|
@param [in] in_str The unquoted, spaced delimited string to transform
|
||||||
@param dlm= the delimeter to be applied to the output (default comma)
|
@param [in] dlm= The delimeter to be applied to the output (default comma)
|
||||||
@param indlm= the delimeter used for the input (default is space)
|
@param [in] indlm= (,) The delimeter used for the input (default is space)
|
||||||
@param quote= the quote mark to apply (S=Single, D=Double). If any other value
|
@param [in] quote= (S) The quote mark to apply (S=Single, D=Double, N=None).
|
||||||
than uppercase S or D is supplied, then that value will be used as the
|
If any other value than uppercase S or D is supplied, then that value will
|
||||||
quoting character.
|
be used as the quoting character.
|
||||||
@return output returns a string with the newly quoted / delimited output.
|
@return output returns a string with the newly quoted / delimited output.
|
||||||
|
|
||||||
@version 9.2
|
@version 9.2
|
||||||
@@ -641,9 +641,10 @@ https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionex
|
|||||||
|
|
||||||
%macro mf_getquotedstr(IN_STR,DLM=%str(,),QUOTE=S,indlm=%str( )
|
%macro mf_getquotedstr(IN_STR,DLM=%str(,),QUOTE=S,indlm=%str( )
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%if "e=S %then %let quote=%str(%');
|
/* credit Rowland Hale - byte34 is double quote, 39 is single quote */
|
||||||
%else %if "e=D %then %let quote=%str(%");
|
%if "e=S %then %let quote=%qsysfunc(byte(39));
|
||||||
%else %let quote=%str();
|
%else %if "e=D %then %let quote=%qsysfunc(byte(34));
|
||||||
|
%else %if "e=N %then %let quote=;
|
||||||
%local i item buffer;
|
%local i item buffer;
|
||||||
%let i=1;
|
%let i=1;
|
||||||
%do %while (%qscan(&IN_STR,&i,%str(&indlm)) ne %str() ) ;
|
%do %while (%qscan(&IN_STR,&i,%str(&indlm)) ne %str() ) ;
|
||||||
@@ -7946,7 +7947,7 @@ run;
|
|||||||
%let tempvw=%mf_getuniquename(prefix=&sysmacroname);
|
%let tempvw=%mf_getuniquename(prefix=&sysmacroname);
|
||||||
proc sql;
|
proc sql;
|
||||||
create view work.&tempvw as select * from &lib..&ds
|
create view work.&tempvw as select * from &lib..&ds
|
||||||
order by %mf_getquotedstr(&sortkey,quote=%str());
|
order by %mf_getquotedstr(&sortkey,quote=N);
|
||||||
|
|
||||||
/* append sorted data */
|
/* append sorted data */
|
||||||
proc append base=&lib..&tempds2 data=work.&tempvw;
|
proc append base=&lib..&tempds2 data=work.&tempvw;
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
for:
|
for:
|
||||||
> "these","words","are","double","quoted"
|
> "these","words","are","double","quoted"
|
||||||
|
|
||||||
@param in_str the unquoted, spaced delimited string to transform
|
@param [in] in_str The unquoted, spaced delimited string to transform
|
||||||
@param dlm= the delimeter to be applied to the output (default comma)
|
@param [in] dlm= The delimeter to be applied to the output (default comma)
|
||||||
@param indlm= the delimeter used for the input (default is space)
|
@param [in] indlm= (,) The delimeter used for the input (default is space)
|
||||||
@param quote= the quote mark to apply (S=Single, D=Double). If any other value
|
@param [in] quote= (S) The quote mark to apply (S=Single, D=Double, N=None).
|
||||||
than uppercase S or D is supplied, then that value will be used as the
|
If any other value than uppercase S or D is supplied, then that value will
|
||||||
quoting character.
|
be used as the quoting character.
|
||||||
@return output returns a string with the newly quoted / delimited output.
|
@return output returns a string with the newly quoted / delimited output.
|
||||||
|
|
||||||
@version 9.2
|
@version 9.2
|
||||||
@@ -30,9 +30,10 @@
|
|||||||
|
|
||||||
%macro mf_getquotedstr(IN_STR,DLM=%str(,),QUOTE=S,indlm=%str( )
|
%macro mf_getquotedstr(IN_STR,DLM=%str(,),QUOTE=S,indlm=%str( )
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%if "e=S %then %let quote=%str(%');
|
/* credit Rowland Hale - byte34 is double quote, 39 is single quote */
|
||||||
%else %if "e=D %then %let quote=%str(%");
|
%if "e=S %then %let quote=%qsysfunc(byte(39));
|
||||||
%else %let quote=%str();
|
%else %if "e=D %then %let quote=%qsysfunc(byte(34));
|
||||||
|
%else %if "e=N %then %let quote=;
|
||||||
%local i item buffer;
|
%local i item buffer;
|
||||||
%let i=1;
|
%let i=1;
|
||||||
%do %while (%qscan(&IN_STR,&i,%str(&indlm)) ne %str() ) ;
|
%do %while (%qscan(&IN_STR,&i,%str(&indlm)) ne %str() ) ;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ run;
|
|||||||
%let tempvw=%mf_getuniquename(prefix=&sysmacroname);
|
%let tempvw=%mf_getuniquename(prefix=&sysmacroname);
|
||||||
proc sql;
|
proc sql;
|
||||||
create view work.&tempvw as select * from &lib..&ds
|
create view work.&tempvw as select * from &lib..&ds
|
||||||
order by %mf_getquotedstr(&sortkey,quote=%str());
|
order by %mf_getquotedstr(&sortkey,quote=N);
|
||||||
|
|
||||||
/* append sorted data */
|
/* append sorted data */
|
||||||
proc append base=&lib..&tempds2 data=work.&tempvw;
|
proc append base=&lib..&tempds2 data=work.&tempvw;
|
||||||
|
|||||||
Reference in New Issue
Block a user