<?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: How to use FML initial format? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694382#M25113</link>
    <description>&lt;P&gt;If all of the values with a comma are in a L,FM layout then this would work. If they are actually in a different order you will have to provide something that lets us know what the different order would be and how to know when.&lt;/P&gt;
&lt;P&gt;Perhaps this can get you started.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   if index(initials,',')&amp;gt;0 then initials =cats(scan(initials,2),scan(initials,1));
run;&lt;/PRE&gt;
&lt;P&gt;I'm sure someone will show a regular expression approach as well.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Oct 2020 22:35:26 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-10-26T22:35:26Z</dc:date>
    <item>
      <title>How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694369#M25112</link>
      <description>&lt;P&gt;I have a data set with initials in the following format: last,firstmiddle (also pictured below)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to format the "Initials" variable so that the initials are displayed first middle last (FML). For example, the second observation should show DNJ instead of J,DN. I also want to leave the "-" symbol for any missing middle initials ( as seen in observation 1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any feedback would be appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694369#M25112</guid>
      <dc:creator>RohanaBruker</dc:creator>
      <dc:date>2020-12-10T15:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694382#M25113</link>
      <description>&lt;P&gt;If all of the values with a comma are in a L,FM layout then this would work. If they are actually in a different order you will have to provide something that lets us know what the different order would be and how to know when.&lt;/P&gt;
&lt;P&gt;Perhaps this can get you started.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   if index(initials,',')&amp;gt;0 then initials =cats(scan(initials,2),scan(initials,1));
run;&lt;/PRE&gt;
&lt;P&gt;I'm sure someone will show a regular expression approach as well.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 22:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694382#M25113</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-26T22:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694389#M25114</link>
      <description>&lt;P&gt;It can be done with FCMP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines;
  length Initials $6;
  input Initials $;
datalines;
M,T-
J,DN
R,JJ
G,MG
F,BC
;
run;

proc fcmp outlib=work.functions.fun  ;
    function InitFLip(string $) $;
      length r $4;
      r = catt(scan(string,2,','),scan(string,1,','));
      return (r);
    endsub;
run;
 
options cmplib=work.functions;    
proc format;
  value $ flip (default=4) other=[InitFLip()];
run;

data want;
  set have;
  format Initials $flip.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Oct 2020 23:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694389#M25114</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-10-26T23:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694427#M25115</link>
      <description>&lt;P&gt;Hi Rohana-&lt;/P&gt;
&lt;P&gt;Based on what we have actually covered in class, I adapted this from the Cancer RCT code example. It appears to get what we want for the initials (FML). I can't find an actual FML function:&lt;/P&gt;
&lt;P&gt;IF MISSING(Initials) = 0 THEN&lt;BR /&gt;Inits = CATS( SUBSTR(UPCASE(Initials), 3, 1), /* 3.3 */&lt;BR /&gt;SUBSTR(UPCASE(Initials), 4, 1),&lt;BR /&gt;SUBSTR(UPCASE(Initials), 1, 1)&lt;BR /&gt;);&lt;BR /&gt;ELSE Inits = CATS( SUBSTR(UPCASE(Initials), 3, 1), /* 3.3 */&lt;BR /&gt;'-',&lt;BR /&gt;SUBSTR(UPCASE(Initials), 1, 1)&lt;BR /&gt;);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;Obs SSN City ZipCd Inits StateCd12345&lt;/P&gt;
&lt;TABLE cellspacing="0" cellpadding="5"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;SSN&lt;/TD&gt;
&lt;TD&gt;City&lt;/TD&gt;
&lt;TD&gt;Zip&lt;/TD&gt;
&lt;TD&gt;Inits&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Note: I don't have all of the code for this dataset done, so it is not sorted by SSN yet. Which means that JGS is not first.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope that helps!&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694427#M25115</guid>
      <dc:creator>dthompsonada</dc:creator>
      <dc:date>2020-12-10T15:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694435#M25116</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339357"&gt;@CurtisMackWSIPP&lt;/a&gt; for providing data in usable form. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344457"&gt;@RohanaBruker&lt;/a&gt; please post data as data step using datalines, not as screenshot, not only to provide something we can actually work with, but to make it easier to read your post, too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here is a solution using a regular expression:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;

   length fml $ 3;
   
   fml = prxchange('s/([A-Z]),(.+)/$2$1/', 1, trim(Initials));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Oct 2020 06:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694435#M25116</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-10-27T06:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694494#M25119</link>
      <description>&lt;P&gt;I love the SCAN solution for its simplicity and speed. But to ensure you preserve the '-' int the original values (indicating that there is no initial in that position) you need to specify comma as the only delimiter for SCAN. This should do the trick:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   /* Split Initials into 2 "words" using SCAN with only comma as delimiter */
   /* Then concatenate the "words" in the desired order */
   initials=cats(scan(initials,-1,','),scan(initials,1,','));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 11:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694494#M25119</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2020-10-27T11:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694695#M25138</link>
      <description>&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 21:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694695#M25138</guid>
      <dc:creator>RohanaBruker</dc:creator>
      <dc:date>2020-10-27T21:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694724#M25140</link>
      <description>Confirmed this code with Laura today!</description>
      <pubDate>Wed, 28 Oct 2020 01:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/694724#M25140</guid>
      <dc:creator>dthompsonada</dc:creator>
      <dc:date>2020-10-28T01:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use FML initial format?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/696916#M25307</link>
      <description>&lt;P&gt;Hello Rohana!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also use the following to code:&lt;/P&gt;&lt;P&gt;Inits = CATS(SUBSTR(Initials,3,2),SUBSTR(Initials,1,1));&lt;/P&gt;&lt;P&gt;The dashes for missing will remain in place for this dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 16:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-FML-initial-format/m-p/696916#M25307</guid>
      <dc:creator>kirstinpruitt</dc:creator>
      <dc:date>2020-11-05T16:08:33Z</dc:date>
    </item>
  </channel>
</rss>

