<?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 chracter to nmeric and remove letters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494184#M130189</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72105"&gt;@lillymaginta&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Make sure to adapt the suggested code if your data contain non-integer values such as "12.5 mg". Otherwise the numeric dose will&amp;nbsp;be wrong (like 125 in my example) because the decimal point will be deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could, for example, list all characters to be deleted in the second argument of the COMPRESS function:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=input(compress(drug,'gmµu'),best.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This would correctly transform values including a decimal point and still remove units "mg", "g", "ug" or "µg".&lt;/P&gt;</description>
    <pubDate>Mon, 10 Sep 2018 16:13:19 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-09-10T16:13:19Z</dc:date>
    <item>
      <title>convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494139#M130165</link>
      <description>&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; $ drug&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;25 mg&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;12 mg&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;13 mg;&lt;/SPAN&gt; 
&lt;SPAN class="token procnames"&gt;Run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I need to create a new data that convert the chracter&amp;nbsp;variable drug to numeric including only the numeric portion of the variable&amp;nbsp;&lt;/P&gt;&lt;P&gt;output&amp;nbsp;&lt;/P&gt;&lt;P&gt;drug&lt;/P&gt;&lt;P&gt;15&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;13&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 14:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494139#M130165</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-10T14:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494143#M130169</link>
      <description>&lt;PRE class="  language-sas"&gt;data have;&lt;BR /&gt; infile datalines dlm=",";&lt;BR /&gt; input drug $;&lt;BR /&gt; want=input(compress(drug,,'kd'),best.);&lt;BR /&gt;datalines;&lt;BR /&gt;25 mg&lt;BR /&gt;12 mg&lt;BR /&gt;13 mg&lt;BR /&gt;; &lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;The compress 'kd' option means keep digits.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 14:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494143#M130169</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-10T14:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494146#M130170</link>
      <description>&lt;P&gt;Thank you RW9 for the prompt response!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 14:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494146#M130170</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-10T14:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494184#M130189</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72105"&gt;@lillymaginta&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Make sure to adapt the suggested code if your data contain non-integer values such as "12.5 mg". Otherwise the numeric dose will&amp;nbsp;be wrong (like 125 in my example) because the decimal point will be deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could, for example, list all characters to be deleted in the second argument of the COMPRESS function:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=input(compress(drug,'gmµu'),best.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This would correctly transform values including a decimal point and still remove units "mg", "g", "ug" or "µg".&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 16:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494184#M130189</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-09-10T16:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494209#M130202</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72105"&gt;@lillymaginta&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Make sure to adapt the suggested code if your data contain non-integer values such as "12.5 mg". Otherwise the numeric dose will&amp;nbsp;be wrong (like 125 in my example) because the decimal point will be deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could, for example, list all characters to be deleted in the second argument of the COMPRESS function:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=input(compress(drug,'gmµu'),best.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This would correctly transform values including a decimal point and still remove units "mg", "g", "ug" or "µg".&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Might be easier to add the decimal indicator to the list of Kept characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(compress(drug,'.','kd'),12.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Sep 2018 17:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494209#M130202</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-09-10T17:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494232#M130211</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72105"&gt;@lillymaginta&lt;/a&gt;&amp;nbsp;I was about to edit the topic title to fix spelling...but then I SEE WHAT YOU DID THERE. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 17:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494232#M130211</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-09-10T17:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494235#M130212</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;for chiming in. I had considered this option, too, but I was thinking that the period might occur in abbreviations (like "gr."). In this case, however, COMPRESS alone wouldn't work anyway (unlike SCAN, PRXCHANGE, ...).&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 18:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494235#M130212</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-09-10T18:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494248#M130213</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;yes there are many possibilities that are not being accounted for.&amp;nbsp;&amp;nbsp;Using SCAN with those same options&amp;nbsp;accounts for your latest&amp;nbsp;scenario.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 440px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23163iEE304BDBF1DE8EB0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 18:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494248#M130213</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-09-10T18:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494255#M130215</link>
      <description>&lt;P&gt;Good point. Cases like "15mg" or "0.5g" are treated correctly as well.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 18:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494255#M130215</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-09-10T18:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494534#M130334</link>
      <description>&lt;P&gt;Thank you data_null, the prior code resulted in large unexpected numbers, I appreciate the follow-up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 16:17:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494534#M130334</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-11T16:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: convert chracter to nmeric and remove letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494621#M130374</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72105"&gt;@lillymaginta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you data_null, the prior code resulted in large unexpected numbers, I appreciate the follow-up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure what you're talking about.&amp;nbsp; What prior code? What unexpected numbers?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 19:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-chracter-to-nmeric-and-remove-letters/m-p/494621#M130374</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-09-11T19:47:18Z</dc:date>
    </item>
  </channel>
</rss>

