<?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: Proc Format &amp;amp; Format Char Variables that starts with certain characters in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/230466#M54495</link>
    <description>&lt;P&gt;Hi PAtrick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reply. It's format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eg,&lt;/P&gt;
&lt;P&gt;I may have under the variable Name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'Tan Peter'&lt;/P&gt;
&lt;P&gt;'Tan John'&lt;/P&gt;
&lt;P&gt;'Mike Tan', ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could have many names containing Tan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to format all Names containing Tan&lt;/P&gt;
&lt;P&gt;into 'the Tans' without listing out all the Names.&lt;/P&gt;
&lt;P&gt;How can i do so?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Oct 2015 06:19:51 GMT</pubDate>
    <dc:creator>apple</dc:creator>
    <dc:date>2015-10-18T06:19:51Z</dc:date>
    <item>
      <title>Proc Format &amp; Format Char Variables that starts with certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/229466#M54394</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am new to SAS, so pardon if my question is simple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to format all my character variables that starts with certain characters. E.G&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) 'ta'&lt;/P&gt;
&lt;P&gt;2) '4' (I have numbers that that are stored as character variables)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2015 06:11:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/229466#M54394</guid>
      <dc:creator>apple</dc:creator>
      <dc:date>2015-10-11T06:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format &amp; Format Char Variables that starts with certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/229471#M54396</link>
      <description>&lt;P&gt;Format or recode? If it's format then your question is actually less trivial than you might think.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you give us a bit a more extensive sample like a few source strings and to what you would like them formatted or recoded?&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2015 12:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/229471#M54396</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-10-11T12:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format &amp; Format Char Variables that starts with certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/230466#M54495</link>
      <description>&lt;P&gt;Hi PAtrick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reply. It's format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eg,&lt;/P&gt;
&lt;P&gt;I may have under the variable Name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'Tan Peter'&lt;/P&gt;
&lt;P&gt;'Tan John'&lt;/P&gt;
&lt;P&gt;'Mike Tan', ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could have many names containing Tan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to format all Names containing Tan&lt;/P&gt;
&lt;P&gt;into 'the Tans' without listing out all the Names.&lt;/P&gt;
&lt;P&gt;How can i do so?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2015 06:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/230466#M54495</guid>
      <dc:creator>apple</dc:creator>
      <dc:date>2015-10-18T06:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Format &amp; Format Char Variables that starts with certain characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/230470#M54496</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2829"&gt;@apple﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The difference between "recoding" and "formatting":&lt;/P&gt;
&lt;P&gt;With recoding you modify the actual internal value of a variable and then assign the result to a new variable.&lt;/P&gt;
&lt;P&gt;With formatting you don't change the internal value but just change the way this value gets printed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe you should go for&amp;nbsp;"recoding". Below an example illustrating how this works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input name $20.;
  datalines;
Tan Peter
Tan John
Mike Tan
John Doe
Tanner Tolbert
;
run;

/* recode */
data want_recoded;
  set have;
  length name_rec $20;
  if findw(upcase(name),'TAN',' ') then name_rec='the Tans';
  else name_rec=name;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The challenge you're facing with names are different spellings and variations (like Bill and William). With names you normally need first to apply some sort of standardization process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below the code sample for&amp;nbsp;"formatting". This code is "advanced" and not what you should be concentrating on if you're "new to SAS".&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input name $20.;
  datalines;
Tan Peter
Tan John
Mike Tan
John Doe
Tanner Tolbert
;
run;

/* format */
proc fcmp outlib=work.funcs.name_recode;
  function name_recode(in_name $) $;
    length out_name $20;
    if findw(upcase(in_name),'TAN',' ') then out_name='the Tans';
    else out_name=in_name;
    return(out_name);
  endsub;
run;

options cmplib=work.funcs;
proc format;
  value $name_group (default=20)
    other = [name_recode()]
  ;
run;

proc print data=have;
  var name;
  format name $name_group.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2015 09:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Format-amp-Format-Char-Variables-that-starts-with-certain/m-p/230470#M54496</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-10-18T09:30:09Z</dc:date>
    </item>
  </channel>
</rss>

