title: Using SUBSTR and CHARINDEX into PROC SQL (SAS)
body: <p>I have written out a SQL query for Microsoft SQL Server, but now I am trying to convert it into SAS PROC SQL and I am running into issues. </p>
  
  <p>Data:</p>
  
  <pre><code>╔══════════╦══════════╦════════╗
  ║   Name   ║ Question ║ Answer ║
  ╠══════════╬══════════╬════════╣
  ║ Jane Doe ║ Q1       ║ Q1-Yes ║
  ║ John Doe ║ Q1       ║ Q1-No  ║
  ╚══════════╩══════════╩════════╝
  </code></pre>
  
  <p>I want to get rid of the "Q1-" in the Answer column and output it as just "Yes" or "No".</p>
  
  <p>In SQL, the code I used is:</p>
  
  <pre><code>SUBSTRING (AnswerTXT, CHARINDEX('-', AnswerTXT)+1, LEN (AnswerTXT)) as 'Answer'
  </code></pre>
  
  <p>In SAS,  I figured out I need to change it in PROC SQL. This is what I got so far:</p>
  
  <pre><code>SELECT SUBSTR(AnswerTXT, 
  </code></pre>
  
  <p>I have tried Index and Scan and keep getting this type of error:</p>
  
  <pre><code>CLI describe error: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]'scan' is not a 
     recognized built-in function name.
  </code></pre>
  
  <p>Thanks!</p>