title: How to create a variable that is a piece of another variable?
body: <p>I would like to create a variable that is simply just part of another variable. I set the new variable equal to the original variable, and then formatted it to do what I wanted, but it still holds the value of the entire original variable. Here is my code:</p>
  
  <pre><code>DATA Names;
     INFILE "......." firstobs=7;
     INPUT Name $ Rank :COMMA6. @@;
     Rank=-Rank;
     FirstTwo = Name;
     Format FirstTwo $2.;
  RUN;
  </code></pre>
  
  <p>I would like to make FirstTwo variable be equal to only the first two letters of Name. With the way I did it, it does not only take the first two letters, it just formats the variable to only be 2 letters. This doesn't help me because later on I would like to sort by FirstTwo, but it still sorts by Name, since FirstTwo is only a FORMAT of Name. Is there any way to make FirstTwo equal to only the first two letters of Name, rather than simply a format of the first two letters?</p>