title: How to create a new variable in SAS by extracting part of the value of an existing numeric variable?
body: <p>I have two datasets in SAS that I would like to merge, but they have no common variables.  One dataset has a "subject_id" variable, while the other has a "mom_subject_id" variable.  Both of these variables are 9-digit codes that have just 3 digits in the middle of the code with common meaning, and that's what I need to match the two datasets on when I merge them.  </p>
  
  <p>What I'd like to do is create a new common variable in each dataset that is just the 3 digits from within the subject ID.  Those 3 digits will always be in the same location within the 9-digit subject ID, so I'm wondering if there's a way to extract those 3 digits from the variable to make a new variable.</p>
  
  <p>Thanks!</p>