<?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: sas substring code extract everything before space in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/501099#M445</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $80.;
x1=scan(x,1,' ');
x2=scan(x,1,,'kd');
cards;
0518Audible adbl.co/bill NJ 01
06257-ELEVEN CHICAGO IL Purchase $33.30 Cash Back $10.00
0625#03345 JEWEL CHICAGO IL Purchase $58.58 Cash Back $20.00 00
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 Oct 2018 12:05:07 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-10-03T12:05:07Z</dc:date>
    <item>
      <title>sas substring code extract everything before space</title>
      <link>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/500944#M428</link>
      <description>&lt;P&gt;I am analyzing data. I need to extract everything from these strings before the first space. How can I extract the substring of everything up to the first space. I am using SAS and have used PRXMATCH but not familiar with doing this. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Removed&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in my output I need:&lt;/P&gt;&lt;PRE&gt;Removed&lt;/PRE&gt;&lt;P&gt;I then need to extract only the first numbers so I get:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Removed&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Any help is greatly appreciated. Thanks much&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 15:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/500944#M428</guid>
      <dc:creator>user112a2</dc:creator>
      <dc:date>2019-04-26T15:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: sas substring code extract everything before space</title>
      <link>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/500951#M429</link>
      <description>&lt;P&gt;string = scan(variablename,1,' ');&lt;/P&gt;
&lt;P&gt;should do it. You should set the length of the target variable string before use though to a long enough value to hold expected results.&lt;/P&gt;
&lt;P&gt;something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;length string $ 100;&lt;/P&gt;
&lt;P&gt;string = scan(variablename,1,' ');&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 20:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/500951#M429</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-02T20:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: sas substring code extract everything before space</title>
      <link>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/501099#M445</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $80.;
x1=scan(x,1,' ');
x2=scan(x,1,,'kd');
cards;
0518Audible adbl.co/bill NJ 01
06257-ELEVEN CHICAGO IL Purchase $33.30 Cash Back $10.00
0625#03345 JEWEL CHICAGO IL Purchase $58.58 Cash Back $20.00 00
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Oct 2018 12:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/501099#M445</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-10-03T12:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: sas substring code extract everything before space</title>
      <link>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/728029#M28253</link>
      <description>&lt;P&gt;For those who may not have followed what Ksharp has done here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) The COUNT of 1 in the SCAN function means that we want to get the FIRST word from the string x. Since COUNT is POSITIVE, SCAN scans words from LEFT to RIGHT within the string x.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) kd is a "SAS Character Function" that retains only numeric values from a string. Similarly, ak is a&amp;nbsp;SAS Character Function that retains only alphabetical&amp;nbsp;values from a string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So here, kd would give us e.g. 06257 for x2 in the second row.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Had ak been used for x2, it would've given us e.g. ELEVEN instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result for x1 here is&amp;nbsp;06257-ELEVEN&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 00:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/sas-substring-code-extract-everything-before-space/m-p/728029#M28253</guid>
      <dc:creator>jjsingh04</dc:creator>
      <dc:date>2021-08-19T00:52:00Z</dc:date>
    </item>
  </channel>
</rss>

