<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Convert height in feet:inches (char) to height in inches (numeric) in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690737#M24767</link>
    <description>&lt;P&gt;You left out the comma before the second argument in the INPUT() function call.&amp;nbsp; Also not sure why you used a width of 3 instead of 2, but that doesn't matter, as long as the width is not shorter then the length of the string being read by the INPUT() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INPUT(SUBSTR(MotherHeight,1,2),3.)&amp;nbsp;*12  + INPUT(SUBSTR(MotherHeight,4,2),3.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that this code assumes that the string always has exactly 5 characters with the colon as the third character.&amp;nbsp; So if the value was '6:1' then it would not work as the first two characters would be '6:' and that will not work with the 3. informat.&amp;nbsp; If the strings are always the same then you might want to use SCAN() instead of SUBSTR() to pull out the pieces.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Oct 2020 21:48:58 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-10-10T21:48:58Z</dc:date>
    <item>
      <title>Convert height in feet:inches (char) to height in inches (numeric)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690725#M24765</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a new variable for height in inches. I want to convert an existing character variable in the format feet:inches (04:11 for example) to a numeric variable in inches (such as 59).&amp;nbsp; I am using SAS Studio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting this error in my log:&lt;/P&gt;&lt;DIV class="sasError"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-10-10 at 14.05.47.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50535i7FD6AE07B9D63E81/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-10-10 at 14.05.47.png" alt="Screen Shot 2020-10-10 at 14.05.47.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Here is my code:&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA lab.study_cohort_2;
	FORMAT race_eth $30.;
	SET lab.study_cohort;

/*Calculate BMI and create categories*/

/*FIRST convert height to inches*/
		IF 			MotherHeight = '?'							THEN 	Ht_Inches 	= 	0;
		ELSE															Ht_Inches	= 
			(INPUT(SUBSTR(MotherHeight,1,2)3.0)*12) + (INPUT(SUBSTR(MotherHeight,4,2)3.0));
RUN;

&lt;/CODE&gt;&lt;/PRE&gt;I am new to SAS and am grateful for some help.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Thanks! &lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 10 Oct 2020 21:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690725#M24765</guid>
      <dc:creator>strong_s</dc:creator>
      <dc:date>2020-10-10T21:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert height in feet:inches (char) to height in inches (numeric)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690726#M24766</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
     char_height='04:11';
     num_height = scan(char_height,1,':')*12 + scan(char_height,2,':')*1;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Oct 2020 21:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690726#M24766</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-10T21:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert height in feet:inches (char) to height in inches (numeric)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690737#M24767</link>
      <description>&lt;P&gt;You left out the comma before the second argument in the INPUT() function call.&amp;nbsp; Also not sure why you used a width of 3 instead of 2, but that doesn't matter, as long as the width is not shorter then the length of the string being read by the INPUT() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INPUT(SUBSTR(MotherHeight,1,2),3.)&amp;nbsp;*12  + INPUT(SUBSTR(MotherHeight,4,2),3.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that this code assumes that the string always has exactly 5 characters with the colon as the third character.&amp;nbsp; So if the value was '6:1' then it would not work as the first two characters would be '6:' and that will not work with the 3. informat.&amp;nbsp; If the strings are always the same then you might want to use SCAN() instead of SUBSTR() to pull out the pieces.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 21:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690737#M24767</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-10T21:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert height in feet:inches (char) to height in inches (numeric)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690758#M24768</link>
      <description>&lt;P&gt;By any chance to you have values with some sort of code for "not collected"? Maybe 99:99 or similar?&lt;/P&gt;
&lt;P&gt;If so you should include such information.&lt;/P&gt;
&lt;P&gt;Or check for it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had a data set from CDC that used a similar character to number coding scheme that managed to 1)not properly check their input program entry and 2) resulted in an adult of 10 inches height that weighed 150 pounds. They had a value like 5010 instead of 0510.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Moral: chech you resulting conversion for reasonable values. If you have adults under 36 inches or anyone over 90 there may be a problem.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 04:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-height-in-feet-inches-char-to-height-in-inches-numeric/m-p/690758#M24768</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-11T04:45:35Z</dc:date>
    </item>
  </channel>
</rss>

