title: SAS create new variable that is the first digit of an existing variable
body: <p>I'm working on some SAS code and ran into an issue. I'm trying to calculate BMI for 6000 plus patients (So datalines isn't an option) using weight and height. Height is currently entered as 508 for 5 feet, 08 inches and so on for every obs. So I figured I would try to combine a substr and input statement to pull the first digit from the 3 digit code, and then do the same for inches. I'll be able to do the rest when I have these two new variables, but I cant seem to get this particular data step to work.</p>
  
  <p>this is what I have:</p>
  
  <pre><code>data work.bmi_prep;
  set work.fixedmissing;
  HEIGHTFT=input(substr(HEIGHT3,1,1),3.);
  run;
  </code></pre>
  
  <p>if someone can tell me where I'm going wrong that would be great.</p>