<?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 Changing data to the same format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Changing-data-to-the-same-format/m-p/736807#M229612</link>
    <description>&lt;P&gt;I'm trying to take maternal height in feet and inches and convert it to just inches. However, I've noticed that some of the data is entered in this format: 05:03 (for 5ft 3 inches) while other entries exclude the colon, so 0503. I'm looking for a way to either add the colon into those that have it missing or remove the colon, so that the data looks the same. Here is the code I was using before I realized this issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MHInch= scan(MotherHeight,1,":")*12 + scan(MotherHeight,2,":")*1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Sun, 25 Apr 2021 04:26:53 GMT</pubDate>
    <dc:creator>abrice520</dc:creator>
    <dc:date>2021-04-25T04:26:53Z</dc:date>
    <item>
      <title>Changing data to the same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-data-to-the-same-format/m-p/736807#M229612</link>
      <description>&lt;P&gt;I'm trying to take maternal height in feet and inches and convert it to just inches. However, I've noticed that some of the data is entered in this format: 05:03 (for 5ft 3 inches) while other entries exclude the colon, so 0503. I'm looking for a way to either add the colon into those that have it missing or remove the colon, so that the data looks the same. Here is the code I was using before I realized this issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MHInch= scan(MotherHeight,1,":")*12 + scan(MotherHeight,2,":")*1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 04:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-data-to-the-same-format/m-p/736807#M229612</guid>
      <dc:creator>abrice520</dc:creator>
      <dc:date>2021-04-25T04:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Changing data to the same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-data-to-the-same-format/m-p/736809#M229614</link>
      <description>&lt;P&gt;As long as you can rely that your source string is always 4 characters after removal of the column below should work.&lt;/P&gt;
&lt;P&gt;If you can't be sure then please provide representative "have" sample data with all the potential patterns the code needs to work for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input MotherHeight $;
  MHInch=sum( 
              input(substr(MotherHeight,1,2),best32.)*12 
              ,input(substr(compress(MotherHeight,':'),3,2),best32.)
            );
datalines;
05:03
0503
;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Code like below could help you figure out what patterns you're dealing with.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select distinct 
    prxchange('s/\d/9/',-1,strip(MotherHeight)) as pattern
  from have
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Apr 2021 06:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-data-to-the-same-format/m-p/736809#M229614</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-25T06:08:04Z</dc:date>
    </item>
  </channel>
</rss>

