<?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 SAS Tip: Retrieving the First Character in SAS Tips from the Community</title>
    <link>https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Retrieving-the-First-Character/m-p/475834#M179</link>
    <description>&lt;P&gt;Have you ever needed to create a variable containing only the first character of a character variable? This&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DATA step&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;shows four different ways to retrieve only the first character. Each new variable (A1, A2, A3, A4) contains only the letter 'F', however the lengths of these four variables are&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;NOT&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;all the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="mw-geshi mw-code mw-content-ltr" dir="ltr"&gt;
&lt;DIV class="sas source-sas"&gt;
&lt;PRE class="de1"&gt;&lt;SPAN class="kw6"&gt;data&lt;/SPAN&gt; one;
    name=&lt;SPAN class="st0"&gt;'Fred'&lt;/SPAN&gt;;
    a1 = &lt;SPAN class="kw3"&gt;substr&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;name,&lt;SPAN class="nu0"&gt;1&lt;/SPAN&gt;,&lt;SPAN class="nu0"&gt;1&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt;;
    a2 = first&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;name&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt;;
    &lt;SPAN class="kw3"&gt;substr&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;a3,&lt;SPAN class="nu0"&gt;1&lt;/SPAN&gt;,&lt;SPAN class="nu0"&gt;1&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt; = name;
    &lt;SPAN class="kw3"&gt;length&lt;/SPAN&gt; a4 $1;
    a4 = name; 
&lt;SPAN class="kw6"&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;This tip was originally published by Art Carpenter on sasCommunity.org.&lt;/EM&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 05 Jul 2018 21:09:03 GMT</pubDate>
    <dc:creator>SAS_Tipster</dc:creator>
    <dc:date>2018-07-05T21:09:03Z</dc:date>
    <item>
      <title>SAS Tip: Retrieving the First Character</title>
      <link>https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Retrieving-the-First-Character/m-p/475834#M179</link>
      <description>&lt;P&gt;Have you ever needed to create a variable containing only the first character of a character variable? This&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DATA step&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;shows four different ways to retrieve only the first character. Each new variable (A1, A2, A3, A4) contains only the letter 'F', however the lengths of these four variables are&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;NOT&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;all the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="mw-geshi mw-code mw-content-ltr" dir="ltr"&gt;
&lt;DIV class="sas source-sas"&gt;
&lt;PRE class="de1"&gt;&lt;SPAN class="kw6"&gt;data&lt;/SPAN&gt; one;
    name=&lt;SPAN class="st0"&gt;'Fred'&lt;/SPAN&gt;;
    a1 = &lt;SPAN class="kw3"&gt;substr&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;name,&lt;SPAN class="nu0"&gt;1&lt;/SPAN&gt;,&lt;SPAN class="nu0"&gt;1&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt;;
    a2 = first&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;name&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt;;
    &lt;SPAN class="kw3"&gt;substr&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;(&lt;/SPAN&gt;a3,&lt;SPAN class="nu0"&gt;1&lt;/SPAN&gt;,&lt;SPAN class="nu0"&gt;1&lt;/SPAN&gt;&lt;SPAN class="br0"&gt;)&lt;/SPAN&gt; = name;
    &lt;SPAN class="kw3"&gt;length&lt;/SPAN&gt; a4 $1;
    a4 = name; 
&lt;SPAN class="kw6"&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;This tip was originally published by Art Carpenter on sasCommunity.org.&lt;/EM&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 05 Jul 2018 21:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Retrieving-the-First-Character/m-p/475834#M179</guid>
      <dc:creator>SAS_Tipster</dc:creator>
      <dc:date>2018-07-05T21:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Tip: Retrieving the First Character</title>
      <link>https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Retrieving-the-First-Character/m-p/475998#M187</link>
      <description>&lt;P&gt;One more function CHAR().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
    name='Fred';
    a1 = char(name,1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jul 2018 13:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Retrieving-the-First-Character/m-p/475998#M187</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-07-06T13:47:10Z</dc:date>
    </item>
  </channel>
</rss>

