<?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 Fixing Char Variable Length in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Fixing-Char-Variable-Length/m-p/702227#M25884</link>
    <description>&lt;P&gt;Hi all! I'm having some issues getting the "inits" variable to be 3 characters and keep all 3 initials. So far, the inits variable is 24 characters and if I add a length statement "Inits $3;" it only outputs the first initial (not FML)&lt;/P&gt;&lt;P&gt;This is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WORK.State;&lt;BR /&gt;SET WORK.State2 (RENAME = (SocSecNum = SSN));&lt;BR /&gt;;&lt;BR /&gt;FirstInit=COMPRESS(FirsitInit, '.');&lt;BR /&gt;xMiddleInit=COMPRESS(MiddleInit, '.');&lt;BR /&gt;xLastInit=COMPRESS(LastInit, '.');&lt;BR /&gt;Inits = FirsitInit || MiddleInit || LastInit;&lt;BR /&gt;Initials = TRANWRD(COMPRESS(Inits, '. '),' ' , '-' );&lt;BR /&gt;Inits = Initials;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2020 15:13:46 GMT</pubDate>
    <dc:creator>cass5957</dc:creator>
    <dc:date>2020-12-10T15:13:46Z</dc:date>
    <item>
      <title>Fixing Char Variable Length</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fixing-Char-Variable-Length/m-p/702227#M25884</link>
      <description>&lt;P&gt;Hi all! I'm having some issues getting the "inits" variable to be 3 characters and keep all 3 initials. So far, the inits variable is 24 characters and if I add a length statement "Inits $3;" it only outputs the first initial (not FML)&lt;/P&gt;&lt;P&gt;This is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WORK.State;&lt;BR /&gt;SET WORK.State2 (RENAME = (SocSecNum = SSN));&lt;BR /&gt;;&lt;BR /&gt;FirstInit=COMPRESS(FirsitInit, '.');&lt;BR /&gt;xMiddleInit=COMPRESS(MiddleInit, '.');&lt;BR /&gt;xLastInit=COMPRESS(LastInit, '.');&lt;BR /&gt;Inits = FirsitInit || MiddleInit || LastInit;&lt;BR /&gt;Initials = TRANWRD(COMPRESS(Inits, '. '),' ' , '-' );&lt;BR /&gt;Inits = Initials;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fixing-Char-Variable-Length/m-p/702227#M25884</guid>
      <dc:creator>cass5957</dc:creator>
      <dc:date>2020-12-10T15:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Fixing Char Variable Length</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fixing-Char-Variable-Length/m-p/702228#M25885</link>
      <description>&lt;P&gt;If you define INITS as length of only 3 and try to assign it a value that is longer than that it will just keep the first three characters.&lt;/P&gt;
&lt;P&gt;In this assignment statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Inits = FirstInit || MiddleInit || LastInit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will only work if each of those other variables are defined with a length of one. For example if FIRSTINIT has a length of 8 then only the first three characters from that variable will fit in the new INITS variable and whatever values the other two variables had wouldn't matter.&lt;/P&gt;
&lt;P&gt;Did you mean?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Inits = char(FirstInit,1)||char(MiddleInit,1)||char(LastInit,1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Nov 2020 23:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fixing-Char-Variable-Length/m-p/702228#M25885</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-28T23:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Fixing Char Variable Length</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fixing-Char-Variable-Length/m-p/702365#M25900</link>
      <description>&lt;P&gt;Hi cass5957!&amp;nbsp;&lt;/P&gt;&lt;P&gt;That was a tricky problem!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code that I used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Inits = CAT(SUBSTR(FirstInit,1,1), SUBSTR(MiddleInit,1,1), SUBSTR(LastInit,1,1));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise if you want to use the compress function I also was able to get this code to work in the same way:&lt;/P&gt;&lt;P&gt;Inits = COMPRESS(CAT(FirstInit, MiddleInit, LastInit), '.');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&amp;nbsp;&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 23:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fixing-Char-Variable-Length/m-p/702365#M25900</guid>
      <dc:creator>txim33</dc:creator>
      <dc:date>2020-11-29T23:10:37Z</dc:date>
    </item>
  </channel>
</rss>

