<?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: Help with extracting first few character of a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353570#M82543</link>
    <description>&lt;P&gt;While SUBSTR does work, it isn't needed when you want only the beginning of a character string:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;length new_char_var $ 5;&lt;/P&gt;
&lt;P&gt;new_char_var = var1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Apr 2017 06:50:26 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-04-26T06:50:26Z</dc:date>
    <item>
      <title>Help with extracting first few character of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353545#M82534</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have text variable and I want to create new variable (new_&lt;SPAN&gt;char_var)&amp;nbsp;&lt;/SPAN&gt;that only keep the first, say 5, character.&lt;/P&gt;
&lt;P&gt;So the new variable will have value:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;vari1&lt;/P&gt;
&lt;P&gt;abcdv&lt;/P&gt;
&lt;P&gt;Can you help me to get it?&lt;/P&gt;
&lt;P&gt;I try to do substring but doesnt work.&lt;/P&gt;
&lt;P&gt;Thank you so much.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input  var1 $;
datalines;
vari1234
abcdv123
;run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Apr 2017 02:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353545#M82534</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2017-04-26T02:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with extracting first few character of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353547#M82536</link>
      <description>&lt;P&gt;substr() does work...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input  var1 $;
newValue = substr(var1,1,5);
datalines;
vari1234
abcdv123
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Apr 2017 02:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353547#M82536</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-04-26T02:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help with extracting first few character of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353570#M82543</link>
      <description>&lt;P&gt;While SUBSTR does work, it isn't needed when you want only the beginning of a character string:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;length new_char_var $ 5;&lt;/P&gt;
&lt;P&gt;new_char_var = var1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 06:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353570#M82543</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-26T06:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with extracting first few character of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353572#M82544</link>
      <description>&lt;P&gt;Show your code (and log) where substr "didn't work".&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have text variable and I want to create new variable (new_&lt;SPAN&gt;char_var)&amp;nbsp;&lt;/SPAN&gt;that only keep the first, say 5, character.&lt;/P&gt;
&lt;P&gt;So the new variable will have value:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;vari1&lt;/P&gt;
&lt;P&gt;abcdv&lt;/P&gt;
&lt;P&gt;Can you help me to get it?&lt;/P&gt;
&lt;P&gt;I try to do substring but doesnt work.&lt;/P&gt;
&lt;P&gt;Thank you so much.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input  var1 $;
datalines;
vari1234
abcdv123
;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 07:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353572#M82544</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-26T07:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with extracting first few character of a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353674#M82569</link>
      <description>&lt;P&gt;If I understood what you mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input  var1 $;
new=scan(var1,1, ,'ka');
datalines;
vari1234
abcdv123
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Apr 2017 12:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-extracting-first-few-character-of-a-string/m-p/353674#M82569</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-26T12:55:50Z</dc:date>
    </item>
  </channel>
</rss>

