title: Create dynamic SAS variable name from string
body: <p>I have something similar to the code below, I want to create every 2 character combination within my strings and then count the occurrence of each and store in a table. I will be changing the substr statement to a do loop to iterate through the whole string. But for now I just want to get the first character pair to work;</p>
  
  <pre><code>data temp;
  input cat $50.;
  call symput ('regex', substr(cat,1,2));
  &amp;regex = count(cat,substr(cat,1,2));
  datalines;
  bvbvbsbvbvbvbvblb
  dvdvdvlxvdvdgd
  cdcdcdcdvdcdcdvcdcded
  udvdvdvdevdvdvdvdvdvdvevdedvdv
  dvdkdkdvdkdkdkudvkdkd
  kdkvdkdkvdkdkvudkdkdukdvdkdkdkdv
  dvkvwduvwdedkd
  ;
  run;
  </code></pre>
  
  <p>Expected results;</p>
  
  <pre><code>cat bv  dv  cd  ud  kd
  ####    6               
  ####        4           
  ####            8       
  ####                1   
  ####        3           
  ####                    9
  ####        1       
  </code></pre>
  
  <p>I'd prefer not to use a proc transpose as I can't loop through the string to create all the character pairs. I'll have to manually create them and I have upto 500 characters per string, plus I would like to search for 3 and 4 string patterns.</p>