## Proc Puzzle Solution

Frequent Contributor
Posts: 88

# The solution to Proc Puzzle

There were 10 Procs in the puzzle, plus 1 created accidentally.

The original compeition was won by Michael Roden, of Canberra.

# PROC PUZZLE

 Y L W Y F N E C B S K R V M N J T T M P D S B J N K W Q E U B M C M O C O A A R N N D A R Q Z K L H J P R K L Z A O N A P I P A N N S D E L E T E S A Q X R X Q B N M R V M J R W C E T L S S C A X E U O S G O I A M V B N A R K E Y U G K G S X X Q G C A T M K A J G Y Z A G K P N Y D C S S Q B M R O H Y X Y R A O C N H T R O P C A A J D N I S Z K N P R L H L K T Y V F R N M P C M Q X R E X R S D D H J T W X C E M T W T R R U Z F T D X A F V P N C T

The Procs are:
PRINT, MEANS, TRANSPOSE, CHART, SORT, RANK, EXPLODE, DELETE, FCMP, CPORT and the 'bonus' one included accidentally, PDS (z/OS specific).

Posts: 3,186

## Re: Proc Puzzle Solution

Posted in reply to JerryLeBreton

If using SAS 9.4 Procedure list (ripped from the link below, 321 procedures in total), we could wound up with 14 hits, 15 if PDS is counted:

data have;

infile test lrecl=30000 truncover;

input var \$30000.;

run;

DATA H1;

length prc \$ 20;

SET HAVE;

IF PRXMATCH('/^<DIV/', STRIP(VAR))>0;

if prxmatch('/><\/A>[A-Z]+\$/', strip(var))>0 then

do;

prc=prxchange('s/(.+)((?<=><\/A>)[A-Z]+\$)/\$2/', -1,strip(var));

output;

end;

else if prxmatch ('>\w+ *\w* *<\/A>',strip(var))>0 then

do;

prc= PRXCHANGE('s/(.+)((?<=">)\w\w+ *\w* *(?=<\/A>))(.+)/\$2/',-1, STRIP(VAR));

if first(prc) ne '<' then

output;

end;

RUN;

filename FT15F001 temp lrecl=512;

data h2;

set h1;

prc=scan(prc,1);

run;

data want;

length string \$ 15;

infile FT15F001 dlm='09'x end=last;

input (v1-v15) (:\$1.);

array v(15) v1-v15;

array str(15,15) \$1. _temporary_;

do i=1 to 15;

str(_n_,i)=v(i);

end;

if last then

do;

/*Horizontal*/

do i=1 to 15;

do j=1 to 15;

string=cats(string,str(i,j));

end;

output;

string=reverse(string);

output;

call missing(string);

end;

/*Vertical*/

do j=1 to 15;

do i=1 to 15;

string=cats(string,str(i,j));

end;

output;

string=reverse(string);

output;

call missing(string);

end;

/*Forward Slash*/

do k=1 to 15;

do i=k by -1 to 1;

j=k+1-i;

string=cats(string,str(i,j));

end;

output;

string=reverse(trim(string));

output;

call missing(string);

end;

do k=15 by -1 to 2;

do i=15 by -1 to k;

j=15+k-i;

string=cats(string,str(i,j));

end;

output;

string=reverse(trim(string));

output;

call missing(string);

end;

/*Backward Slash*/

do k=2 to 15;

do i=1 to k;

j=15-k+i;

string=cats(string,str(i,j));

end;

output;

string=reverse(trim(string));

output;

call missing(string);

end;

do k=15 by -1 to 2;

do i=15 by -1 to k;

j=i-k+1;

string=cats(string,str(i,j));

end;

output;

string=reverse(trim(string));

output;

call missing(string);

end;

end;

keep string;

parmcards;

Y    L    W    Y    F    N    E    C    B    S    K    R    V    M    N

J    T    T    M    P    D    S    B    J    N    K    W    Q    E    U

B    M    C    M    O    C    O    A    A    R    N    N    D    A    R

Q    Z    K    L    H    J    P    R    K    L    Z    A    O    N    A

P    I    P    A    N    N    S    D    E    L    E    T    E    S    A

Q    X    R    X    Q    B    N    M    R    V    M    J    R    W    C

E    T    L    S    S    C    A    X    E    U    O    S    G    O    I

A    M    V    B    N    A    R    K    E    Y    U    G    K    G    S

X    X    Q    G    C    A    T    M    K    A    J    G    Y    Z    A

G    K    P    N    Y    D    C    S    S    Q    B    M    R    O    H

Y    X    Y    R    A    O    C    N    H    T    R    O    P    C    A

A    J    D    N    I    S    Z    K    N    P    R    L    H    L    K

T    Y    V    F    R    N    M    P    C    M    Q    X    R    E    X

R    S    D    D    H    J    T    W    X    C    E    M    T    W    T

R    R    U    Z    F    T    D    X    A    F    V    P    N    C    T

;

run;

proc sql;

create table procs as

select distinct prc from

h2, want

where find(string,strip(prc))>0;

quit;

 CHART CPM CPORT DELETE EXPLODE FCMP GA LP MEANS PM PRINT RANK SORT TRANSPOSE

Haikuo

Posts: 1,406

## Re: Proc Puzzle Solution

Posted in reply to JerryLeBreton

I like your clever response to the puzzle, Haikuo! Nice use of SAS functions including Perl regular expressions and SAS arrays.

Cheers,

Michelle

Posts: 3,186

## Re: Proc Puzzle Solution

Posted in reply to JerryLeBreton

Thanks for the compliment, Michelle!

Haikuo

Discussion stats
• 3 replies
• 312 views
• 1 like
• 3 in conversation