<?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: trimming variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611714#M178339</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153469"&gt;@radhikaa4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to just pick out the middle instance of "have_id"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;have_id&lt;/TD&gt;
&lt;TD&gt;want_id&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1234-ABCD-5678&lt;/TD&gt;
&lt;TD&gt;ABCD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6564-DGFD-4958&lt;/TD&gt;
&lt;TD&gt;DGFD&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently I used&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select have_id, right(left(subjectID, 9), 4) as want_id&lt;/P&gt;
&lt;P&gt;from testdata; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it works in my sql server but not in the SAS. any help would be great!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;LEFT() and RIGHT() do not take any numeric arguments, just the string that want to left align or right align.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why wouldn't you just use the SUBSTR() function in either SQL server or SAS?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(subjectid,6,4)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2019 19:47:34 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-12-13T19:47:34Z</dc:date>
    <item>
      <title>trimming variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611575#M178259</link>
      <description>&lt;P&gt;I want to just pick out the middle instance of "have_id"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;have_id&lt;/TD&gt;&lt;TD&gt;want_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234-ABCD-5678&lt;/TD&gt;&lt;TD&gt;ABCD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6564-DGFD-4958&lt;/TD&gt;&lt;TD&gt;DGFD&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I used&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select have_id, right(left(subjectID, 9), 4) as want_id&lt;/P&gt;&lt;P&gt;from testdata; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it works in my sql server but not in the SAS. any help would be great!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 14:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611575#M178259</guid>
      <dc:creator>radhikaa4</dc:creator>
      <dc:date>2019-12-13T14:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: trimming variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611579#M178263</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153469"&gt;@radhikaa4&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input have_id $30.;
cards;	
1234-ABCD-5678	
6564-DGFD-4958	
;

data want;
set have;
want_id=scan(have_id,median(1,countw(have_id,'-')),'-');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 14:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611579#M178263</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-13T14:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: trimming variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611707#M178335</link>
      <description>&lt;P&gt;If your values are all as simple as you display then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;scan(have_id,2,'-') as want_id&lt;/P&gt;
&lt;P&gt;should work.&lt;/P&gt;
&lt;P&gt;This assumes that you always have at least 1 hyphen character and that the part you want is bit immediately after the first hyphen. The hyphen in the scan is telling the SCAN function to use only the hyphen as a word delimiter so other characters such as space, * , slash , period, question mark and most punctuation&amp;nbsp;would be ignored for determining word boundaries. If you have other characters that need to be considered then a more comprehensive example should be provided.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 19:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611707#M178335</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-13T19:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: trimming variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611714#M178339</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153469"&gt;@radhikaa4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to just pick out the middle instance of "have_id"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;have_id&lt;/TD&gt;
&lt;TD&gt;want_id&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1234-ABCD-5678&lt;/TD&gt;
&lt;TD&gt;ABCD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6564-DGFD-4958&lt;/TD&gt;
&lt;TD&gt;DGFD&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently I used&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select have_id, right(left(subjectID, 9), 4) as want_id&lt;/P&gt;
&lt;P&gt;from testdata; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it works in my sql server but not in the SAS. any help would be great!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;LEFT() and RIGHT() do not take any numeric arguments, just the string that want to left align or right align.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why wouldn't you just use the SUBSTR() function in either SQL server or SAS?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(subjectid,6,4)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 19:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trimming-variable/m-p/611714#M178339</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-13T19:47:34Z</dc:date>
    </item>
  </channel>
</rss>

