/***tip00402 ***/
/***To Do a Hash Total on a Character Field to determine if you read a field
    correctly ***/
/*** this example assumes all special characters are assigned '00' values ***/
/*** Author: Charles Patridge ***/
 proc format;
  value $chrhash
  '0'=0
  '1'=1
  '2'=2
  '3'=3
  '4'=4
  '5'=5
  '6'=6
  '7'=7
  '8'=8
  '9'=9
  'A','a'=11
  'B','b'=12
  'C','c'=13
  'D','d'=14
  'E','e'=15
  'F','f'=16
  'G','g'=17
  'H','h'=18
  'I','i'=19
  'J','j'=20
  'K','k'=21
  'L','l'=22
  'M','m'=23
  'N','n'=24
  'O','o'=25
  'P','p'=26
  'Q','q'=27
  'R','r'=28
  'S','s'=29
  'T','t'=30
  'U','u'=31
  'V','v'=32
  'W','w'=33
  'X','x'=34
  'Y','y'=35
  'Z','z'=36
  other = 00
 ;
run;


 %macro hashchar(_hshvar_=, _sasvar_= );
/*** _hshvar_ is the numeric summed values of the characters read ***/
/*** _sasvar_ is the character variable to read ***/

   &_hshvar_ = 0;
   do _i_ = 1 to length(&_sasvar_);
     &_hshvar_ + input(put(substr(&_sasvar_,_i_,1),$chrhash.), 2.);
   end;
   drop _i_ ;
 %mend hashchar;


data test ;
 infile cards missover;
 input ;
 record = _infile_;
cards;
  123 !@#$%^&*()_+-=[]{}\|<.,>?/charlespatridge..
123charlespatridge
;;;;
run;

data test;
 set test;

 %hashchar( _sasvar_=record, _hshvar_=record_hash );

run;

/*** end of tip 00402 ***/