Proc Puzzle

Reply
Frequent Contributor
Posts: 85

Proc Puzzle

Didn't know there was a Proc Puzzle?  Well, maybe there isn't, but how familiar are you with all the Base SAS Procedures - there are quite a lot?

Competion closed - won by Michael Roden of Canberra


This competition was run in early 2014 and Michael Roden won a SAS publication for his winning entry.

If you missed the competition, you can still enjoy Proc Puzzle though...

How many Proc names can you find hidden in the puzzle?  They are only Base SAS Procedures, so how hard can it be?

You can simply eyeball the puzzle or maybe write some fancy SAS code to help.

Proc names are in straight lines but may be across, down, up, diagonal, left to right, or right to left.

And you can check the answers .

PROC PUZZLE

YLWYFNECBSKRVMN
JTTMPDSBJNKWQEU
BMCMOCOAARNNDAR
QZKLHJPRKLZAONA
PIPANNSDELETESA
QXRXQBNMRVMJRWC
ETLSSCAXEUOSGOI
AMVBNARKEYUGKGS
XXQGCATMKAJGYZA
GKPNYDCSSQBMROH
YXYRAOCNHTROPCA
AJDNISZKNPRLHLK
TYVFRNMPCMQXREX
RSDDHJTWXCEMTWT
RRUZFTDXAFVPNCT

Enjoy!

Occasional Contributor
Posts: 5

Re: Proc Puzzle

Am I winning?   I have found 5 proc names.


Super User
Posts: 1,223

Re: Proc Puzzle

I've found 8 procs... - any clues as to how many procs there are? How about a range?

Frequent Contributor
Posts: 85

Re: Proc Puzzle

Sorry , no clues.

 

(Because I've lost the answers!  So its all based on members' responses.)

Contributor
Posts: 23

Re: Proc Puzzle

I found 9 .. just need to confirm if they are all in base

Super User
Posts: 1,223

Re: Proc Puzzle

- question came through above about whether all the procs are all in Base SAS. From your description above it seems to be. Please confirm.

I also noticed that the proc puzzle ends at the end of the month - a few weeks left so get "proc"-ing :smileymischief:

Frequent Contributor
Posts: 85

Re: Proc Puzzle

Hi

Yes, all the procs are purely BASE SAS only.

Happy proc hunting everyone.

Trusted Advisor
Posts: 1,297

Re: Proc Puzzle

Nice puzzle

/** PROC Puzzle -

*

*     Reference: https://communities.sas.com/docs/DOC-2431

*

*     Author: FriedEgg, 10/6/2014

*/

filename _x url 'http://support.sas.com/documentation/cdl/en/allprodsproc/67392/HTML/default/p1vzipzy6l8so0n1gbbh3ae6...' recfm=v;

data procs;

length proc $ 32;

keep proc;

retain re;

if _n_=1 then do;

   re=prxparse('/(?<=title="">)([^<\ ]+)[^<]*(?=<\/A>)/');

   do proc='EXPLODE','SPELL','BROWSE','NICKNAME','NEIGHBOR','EDITOR','CHART';

      output;

   end;

end;

infile _x dlm='< :' end=done;

input @;

rc=prxmatch(re, _infile_);

if rc then do;

   proc=compress(prxposn(re, 1, _infile_));

   output;

end;

run;

proc sort data=procs nodupkey; by proc; run;

proc ds2;

data _null_;

dcl char(1) board[15,15];

dcl char(32) proc;

dcl package hash words([proc], 0, 'procs');

dcl int matches;

method wordsearch(char string) returns int;

   dcl int match;

   dcl double rc;

   dcl char(32) lproc;

   dcl package hiter iter;

   match=0;

   iter = _new_ hiter('words');

   rc=iter.first();

   do while(rc=0);

      rc=(find(string, proc, 'it')>0);

      if rc then do;

         iter.delete();

         words.remove();

         iter = _new_ hiter('words');

         if missing(lproc) then rc=iter.first();

         else do;

            proc=lproc;

            iter.setcur();

         end;

      end;

      if rc then put 'Found ' proc;

      match+rc;

      rc=iter.next();

      lproc=proc;

   end;

   return match;

end;

method search(int row,int col,int rdelta,int cdelta) returns int;

   dcl int matches i j result;

   dcl char(15) string;

   matches = 0;

   if rdelta=0 and cdelta=0 then return 0;

   string = board[row, col];

   i = row + rdelta;

   j = col + cdelta;

   do while(i>0 and j>0 and i<=dim(board,1) and j<=dim(board,2));

      string = cats(string, board[i, j]);

      result = wordsearch(string);

      this.matches+result;

      i+rdelta;

      j+cdelta;

   end;

   return this.matches;

end;

method solve();

   dcl int r c rd cd matches;

   matches = 0;

   do r = 1 to dim(board,1);

      do c = 1 to dim(board,2);

         do rd = -1 to 1;

            do cd = -1 to 1;

               matches + search(r, c, rd, cd);

            end;

         end;

      end;

   end;

end;

method init();

   board := (

      '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'

   );

   solve();

   put matches=;

end;

enddata;

run;

quit;

Super User
Posts: 1,223

Re: Proc Puzzle

Nice use of DS2 ! Smiley Happy

Grand Advisor
Posts: 9,466

Re: Proc Puzzle

When did this puzzle post ? I didn't see it . Anyway, I like puzzle. Here is what I got .

data key;
input key : $upcase20.;
cards;
APPEND 
CALENDAR 
CALLRFC 
CATALOG 
CHART 
CIMPORT 
COMPARE 
CONTENTS 
COPY 
CORR 
CPORT 
CV2VIEW 
DATASETS 
DBCSTAB 
DISPLAY 
DOCUMENT 
DELETE
EXPLODE 
EXPORT 
FCMP 
FONTREG 
FORMAT 
FORMS 
FREQ 
FSLIST 
HTTP 
IMPORT 
INFOMAPS 
JAVAINFO 
MEANS 
METADATA 
METALIB 
METAOPERATE 
MIGRATE 
OPTIONS 
OPTLOAD 
OPTSAVE 
PLOT 
PMENU 
PRINT 
PRINTTO 
PROTO 
PRTDEF 
PRTEXP 
PWENCODE 
PDS 
RANK 
REGISTRY 
REPORT 
SCAPROC 
SOAP 
SORT 
SQL 
STANDARD 
SUMMARY 
TABULATE 
TEMPLATE
TIMEPLOT 
TRANSPOSE 
TRANTAB 
UNIVARIATE 
XSL 
;
run;

data map;
do x=1 to 15;
 do y=1 to 15;
  input value : $upcase8. @@;output;
 end;
end;
cards;
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;

data _null_;
if _n_ eq 1 then do;
  if 0 then set key;
  declare hash k(dataset:'key');
   k.definekey('key');
   k.definedone();

  if 0 then set map(rename=(x=_x y=_y value=_value));
  declare hash m(dataset:'map(rename=(x=_x y=_y value=_value))');
   m.definekey('_x','_y');
   m.definedata('_value');
   m.definedone();
end;
set map;
/*negative y-axis*/
key=value; 
_x=x+1;_y=y;
do while(_x lt 16);
 m.find();
 key=cats(key,_value); 
 if k.check()=0 then putlog 'Found it at: row ' _x 'col ' _y key;
 _x+1;
end;
/*positive y-axis*/
key=value; 
_x=x-1;_y=y;
do while(_x gt 0);
 m.find();
 key=cats(key,_value);  
 if k.check()=0 then putlog 'Found it at: row ' _x 'col ' _y key;
 _x+(-1);
end;
/*negative x-axis*/
key=value; 
_x=x;_y=y-1;
do while(_y gt 0);
 m.find();
 key=cats(key,_value);  
 if k.check()=0 then putlog 'Found it at: row ' _x 'col ' _y key;
 _y+(-1);
end;
/*positive x-axis*/
key=value; 
_x=x;_y=y+1;
do while(_y lt 16);
 m.find();
 key=cats(key,_value);  
 if k.check()=0 then putlog 'Found it at: row ' _x 'col ' _y key;
 _y+1;
end;
/*south-east axis*/
key=value; 
_x=x+1;_y=y+1;
do while(_x lt 16 and _y lt 16);
 m.find();
 key=cats(key,_value); 
 if k.check()=0 then putlog 'Found it at: row ' _x 'col ' _y key;
 _x+1;_y+1;
end;
/*south-west axis*/
key=value; 
_x=x+1;_y=y-1;
do while(_x lt 16 and _y gt 0);
 m.find();
 key=cats(key,_value);  
 if k.check()=0 then putlog 'Found it at: row ' _x 'col ' _y key;
 _x+1;_y+(-1);
end;
/*north-west axis*/
key=value; 
_x=x-1;_y=y-1;
do while(_x gt 0 and _y gt 0);
 m.find();
 key=cats(key,_value);  
 if k.check()=0 then putlog 'Found it at: row ' _x 'col ' _y key;
 _x+(-1);_y+(-1);
end;
/*north-east axis*/
key=value; 
_x=x-1;_y=y+1;
do while(_x gt 0 and _y lt 16);
 m.find();
 key=cats(key,_value);  
 if k.check()=0 then putlog 'Found it at: row ' _x 'col ' _y key;
 _x+(-1);_y+1;
end;
run;















NOTE: 从数据集 WORK.KEY. 读取了 62 个观测
NOTE: 从数据集 WORK.MAP. 读取了 225 个观测
Found it at: row 5 col 14 MEANS
Found it at: row 2 col 7 PDS
Found it at: row 7 col 2 CHART
Found it at: row 1 col 11 RANK
Found it at: row 5 col 13 DELETE
Found it at: row 1 col 7 EXPLODE
Found it at: row 5 col 12 SORT
Found it at: row 1 col 7 TRANSPOSE
Found it at: row 14 col 7 PRINT
Found it at: row 11 col 10 CPORT
Found it at: row 12 col 10 FCMP
NOTE: 从数据集 WORK.MAP. 读取了 225 个观测
NOTE: “DATA 语句”所用时间(总处理时间):
      实际时间          0.09 秒
      CPU 时间          0.09 秒


Xia Keshan

Ask a Question
Discussion stats
  • 9 replies
  • 744 views
  • 3 likes
  • 6 in conversation