Search code examples
stringsascharacterenterprise-guide

SAS EG Character Functions


I have two tables containing characters:

      First_Column            Second Column
          aaa                   123aaa123
          bbb                   cdsbbbsxd
          ccc                   098fdsccd

I want to label 1 if Second Column string contains the string in the first column otherwise I would like put 0.

I could not find a way to do that in SAS EG? Is there any function to do this?

Thanks


Solution

  • You can use functions like find, index or count.

    count('Second Column'n, First_Column)
    
    index('Second Column'n, First_Column)
    
    find('Second Column'n, First_Column)
    

    In Query Builder you have to add new column with an expression like below:

    case(count('Second Column'n, First_Column))
      when(0) then 0
      else 1
    end