<?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: Need help with code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752202#M236916</link>
    <description>&lt;P&gt;can you provide me the compress function code to get only the number and hypen.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jul 2021 04:31:20 GMT</pubDate>
    <dc:creator>Sultana</dc:creator>
    <dc:date>2021-07-06T04:31:20Z</dc:date>
    <item>
      <title>Need help with code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752199#M236913</link>
      <description>&lt;P&gt;Here is a sample data set where column 1 is the ID which has the employees name and number&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only want the numbers to be outputted&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Robert, Andrews 222-22-1234&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;1,234.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Albert, Sanders 123-45-6789&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;TD&gt;2,34.67&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Zack, Snyder 111-22-3333&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;1,234.77&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the following output&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;222-22-1234&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;1,234.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123-45-6789&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;TD&gt;2,34.67&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111-22-3333&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;1,234.77&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;input ID&amp;nbsp; &amp;nbsp;: $12&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Year : Year.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Amount: comma13.&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how to only the ID numbers in the output table no names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 04:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752199#M236913</guid>
      <dc:creator>Sultana</dc:creator>
      <dc:date>2021-07-06T04:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752200#M236914</link>
      <description>&lt;P&gt;A very simple way would be to use the &lt;FONT face="courier new,courier"&gt;anydigit()&lt;/FONT&gt;&amp;nbsp;function inside the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;substr()&lt;/FONT&gt;&amp;nbsp;function .&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 04:15:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752200#M236914</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-06T04:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752201#M236915</link>
      <description>&lt;P&gt;There are several ways you can do this:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;compress-function to keep only numbers and hyphen.&lt;/LI&gt;
&lt;LI&gt;regular expression with prxchange&lt;/LI&gt;
&lt;LI&gt;anydigit-function to get the position of the first number, then substr to extract the number.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;I am sure that after having the a quick look at the documentation of the functions, you are able to solve the problem. If not, please post data in usable form and the code you already have.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 04:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752201#M236915</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-06T04:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752202#M236916</link>
      <description>&lt;P&gt;can you provide me the compress function code to get only the number and hypen.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 04:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752202#M236916</guid>
      <dc:creator>Sultana</dc:creator>
      <dc:date>2021-07-06T04:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752204#M236918</link>
      <description>&lt;P&gt;What have you tried? Being able to read the docs and find required information is a necessary skill to learn a programming language.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;want = compress(have, '-', 'kd');&lt;/LI-SPOILER&gt;</description>
      <pubDate>Tue, 06 Jul 2021 05:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752204#M236918</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-06T05:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752268#M236941</link>
      <description>&lt;P&gt;Your ID has a clear pattern for a SCAN function starting from&lt;EM&gt; right to left-&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; length want_id $15;
 want_id=scan(id,-1,' ');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  infile cards truncover expandtabs ;
  input ID $28.	Date	Amount :comma10. ;
  format amount comma10.2 ;
  cards;
Robert, Andrews 222-22-1234	2019	1,234.00
Albert, Sanders 123-45-6789	2018	2,34.67
Zack, Snyder 111-22-3333	2020	1,234.77
;

data want ;
 set have ;
 length want_id $15 ;
 want_id=scan(id,-1,' ') ;
run ;

proc print noobs ; run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Amount&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;want_id&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Robert, Andrews 222-22-1234&lt;/TD&gt;
&lt;TD class="r data"&gt;2019&lt;/TD&gt;
&lt;TD class="r data"&gt;1,234.00&lt;/TD&gt;
&lt;TD class="l data"&gt;222-22-1234&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Albert, Sanders 123-45-6789&lt;/TD&gt;
&lt;TD class="r data"&gt;2018&lt;/TD&gt;
&lt;TD class="r data"&gt;234.67&lt;/TD&gt;
&lt;TD class="l data"&gt;123-45-6789&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Zack, Snyder 111-22-3333&lt;/TD&gt;
&lt;TD class="r data"&gt;2020&lt;/TD&gt;
&lt;TD class="r data"&gt;1,234.77&lt;/TD&gt;
&lt;TD class="l data"&gt;111-22-3333&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 12:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-code/m-p/752268#M236941</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-07-06T12:36:23Z</dc:date>
    </item>
  </channel>
</rss>

