<?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: How to convert inches into numeric ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739773#M230946</link>
    <description>&lt;P&gt;Slight bug in my prior code as I didn't account for more than a single digit for inches.&lt;BR /&gt;Need to add the * metacharacter to the regular expression definition:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;regExpID=prxparse("/(\d* \d\/\d)|(\d\/\d)|(\d)/") ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 May 2021 13:49:35 GMT</pubDate>
    <dc:creator>AMSAS</dc:creator>
    <dc:date>2021-05-07T13:49:35Z</dc:date>
    <item>
      <title>How to convert inches into numeric ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739757#M230938</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one column.&lt;/P&gt;
&lt;P&gt;There is some value like 1",2",1/2",1 1/2".......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone explain how to convert this value in numeric ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Nirav&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 13:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739757#M230938</guid>
      <dc:creator>NiravC</dc:creator>
      <dc:date>2021-05-07T13:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert inches into numeric ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739770#M230944</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;Simple strip of the " and convert it to number. Use substr function.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 13:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739770#M230944</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-05-07T13:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert inches into numeric ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739771#M230945</link>
      <description>&lt;P&gt;Here's a solution using regular expression matching&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data got ;
	input inches $6. ;
cards ;
1"
2"
1/2"
1 1/2"
2"
3 3/4"
;

data want ;
	retain regExpID ;
	if _n_=1 then do ;
		/* Create regular expression to search for i n/d format e.g. 1, 1/2 or 2 1/2 */
		regExpID=prxparse("/(\d \d\/\d)|(\d\/\d)|(\d)/") ;
		put regExpID= ;
	end ;
	set got ;
	int=0 ;
	numerator=0 ;
	denominator=0 ;
	/* does the input string inches fit the formats */
	position=prxmatch(regExpID, inches);
	if position then do ;
		paren=prxparen(regExpID);		
		/* If the matching format is i */
		if paren=3 then do ;
			int=inputn(scan(inches,1,' /"'),"8.") ;
		end ;
		/* If the matching format is n/d */
		else if paren=2 then do ;
			numerator=inputn(scan(inches,1,' /"'),"8.") ;
			denominator=inputn(scan(inches,2,' /"'),"8.") ;
		end ;
		/* If the matching format is i n/d */
		else do ;
			int=inputn(scan(inches,1,' /"'),"8.") ;
			numerator=inputn(scan(inches,2,' /"'),"8.") ;
			denominator=inputn(scan(inches,3,' /"'),"8.") ;
			
		end ;
	end ;
	put int= numerator= denominator= ;
run ;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 May 2021 13:42:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739771#M230945</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-05-07T13:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert inches into numeric ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739773#M230946</link>
      <description>&lt;P&gt;Slight bug in my prior code as I didn't account for more than a single digit for inches.&lt;BR /&gt;Need to add the * metacharacter to the regular expression definition:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;regExpID=prxparse("/(\d* \d\/\d)|(\d\/\d)|(\d)/") ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 May 2021 13:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739773#M230946</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-05-07T13:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert inches into numeric ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739777#M230947</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279720"&gt;@NiravC&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279720"&gt;@NiravC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;There is some value like 1",2",1/2",1 1/2".......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone explain how to convert this value in numeric ?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you want, e.g., &lt;FONT face="courier new,courier"&gt;1.5&lt;/FONT&gt; for &lt;FONT face="courier new,courier"&gt;1 1/2"&lt;/FONT&gt;? If so, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input inches_c $10.;
cards ;
1"
1/2"
1 1/2"
12 7/8"
123 13/16"
;

data want;
set have;
inches=input(resolve(cats('%sysevalf(',translate(trim(inches_c),'+',' "'),')')),32.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 May 2021 14:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739777#M230947</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-05-07T14:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert inches into numeric ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739787#M230950</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279720"&gt;@NiravC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one column.&lt;/P&gt;
&lt;P&gt;There is some value like 1",2",1/2",1 1/2".......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone explain how to convert this value in numeric ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Nirav&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do any of these "inch" measurements happen to also include feet? Such as 1' 8 1/2" ?&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 14:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739787#M230950</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-07T14:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert inches into numeric ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739797#M230954</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;SPAN style="font-family: inherit; font-size: 16px;"&gt;Do any of these "inch" measurements happen to also include feet? Such as 1' 8 1/2" ?&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good point!&lt;/P&gt;
&lt;P&gt;A slight extension of the nested-functions approach can deal with this possibility:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;inches=input(resolve(cats('%sysevalf(',tranwrd(translate(trim(inches_c),'+',' "'),"'","*12"),')')),32.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 15:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/739797#M230954</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-05-07T15:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert inches into numeric ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/740035#M231095</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is very helpfull for me. Thank you for giving me this solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nirav Chaudhari&lt;/P&gt;</description>
      <pubDate>Sun, 09 May 2021 09:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-inches-into-numeric/m-p/740035#M231095</guid>
      <dc:creator>NiravC</dc:creator>
      <dc:date>2021-05-09T09:42:41Z</dc:date>
    </item>
  </channel>
</rss>

