Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Palindrome-detection/SAS/palindrome-detection-1.sas
Normal file
5
Task/Palindrome-detection/SAS/palindrome-detection-1.sas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
The macro "palindro" has two parameters: string and ignorewhitespace.
|
||||
string is the expression to be checked.
|
||||
ignorewhitespace, (Y/N), determines whether or not to ignore blanks and punctuation.
|
||||
This macro was written in SAS 9.2. If you use a version before SAS 9.1.3,
|
||||
the compress function options will not work.
|
||||
24
Task/Palindrome-detection/SAS/palindrome-detection-2.sas
Normal file
24
Task/Palindrome-detection/SAS/palindrome-detection-2.sas
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
%MACRO palindro(string, ignorewhitespace);
|
||||
DATA _NULL_;
|
||||
%IF %UPCASE(&ignorewhitespace)=Y %THEN %DO;
|
||||
/* The arguments of COMPRESS (sp) ignore blanks and puncutation */
|
||||
/* We take the string and record it in reverse order using the REVERSE function. */
|
||||
%LET rev=%SYSFUNC(REVERSE(%SYSFUNC(COMPRESS(&string,,sp))));
|
||||
%LET string=%SYSFUNC(COMPRESS(&string.,,sp));
|
||||
%END;
|
||||
|
||||
%ELSE %DO;
|
||||
%LET rev=%SYSFUNC(REVERSE(&string));
|
||||
%END;
|
||||
/*%PUT rev=&rev.;*/
|
||||
/*%PUT string=&string.;*/
|
||||
|
||||
/* Here we determine if the string and its reverse are the same. */
|
||||
%IF %UPCASE(&string)=%UPCASE(&rev.) %THEN %DO;
|
||||
%PUT TRUE;
|
||||
%END;
|
||||
%ELSE %DO;
|
||||
%PUT FALSE;
|
||||
%END;
|
||||
RUN;
|
||||
%MEND;
|
||||
15
Task/Palindrome-detection/SAS/palindrome-detection-3.sas
Normal file
15
Task/Palindrome-detection/SAS/palindrome-detection-3.sas
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
%palindro("a man, a plan, a canal: panama",y);
|
||||
|
||||
TRUE
|
||||
|
||||
NOTE: DATA statement used (Total process time):
|
||||
real time 0.00 seconds
|
||||
cpu time 0.00 seconds
|
||||
|
||||
%palindro("a man, a plan, a canal: panama",n);
|
||||
|
||||
FALSE
|
||||
|
||||
NOTE: DATA statement used (Total process time):
|
||||
real time 0.00 seconds
|
||||
cpu time 0.00 seconds
|
||||
Loading…
Add table
Add a link
Reference in a new issue