<?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: SSN formatting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802737#M316051</link>
    <description>&lt;P&gt;When you say "mostly&amp;nbsp; 4 digit numbers" two question come to mind: Is the value actual a SAS numeric variable or character containing digits? and what kind of values are the not exactly 4 digits?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the variable is numeric &lt;STRONG&gt;and&lt;/STRONG&gt; none of the numeric values are greater than 9999 a custom format would likely be easiest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
picture fakessn  (default=11)
low-high = '9999'  (prefix='xxx-xx-');
run;&lt;/PRE&gt;
&lt;P&gt;In a picture the string '9999' means that 4 digits will be displayed so if a value is less than 1000 it will be padded with leading 0. The prefix text should be fairly obvious.&lt;/P&gt;
&lt;P&gt;Associate the format with the variable when you want to display it. You would need to make sure the format was available in any SAS session that you want to use this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can run this code after the Proc Format is run to see what the results look like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  do x = 0,1,10,100,1000,4567;
    put x fakessn.;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Look in the log to see the result.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Mar 2022 05:01:33 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-03-18T05:01:33Z</dc:date>
    <item>
      <title>SSN formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802719#M316038</link>
      <description>&lt;P&gt;SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set with mostly 4 digit numbers and I would like to have them as a character variable "xxx-xx-4 digit number sequence'. Is there an efficient way to program this? Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 23:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802719#M316038</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-03-17T23:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: SSN formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802723#M316042</link>
      <description>Can you provide specific samples of the original data and desired results?</description>
      <pubDate>Fri, 18 Mar 2022 00:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802723#M316042</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-03-18T00:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: SSN formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802737#M316051</link>
      <description>&lt;P&gt;When you say "mostly&amp;nbsp; 4 digit numbers" two question come to mind: Is the value actual a SAS numeric variable or character containing digits? and what kind of values are the not exactly 4 digits?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the variable is numeric &lt;STRONG&gt;and&lt;/STRONG&gt; none of the numeric values are greater than 9999 a custom format would likely be easiest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
picture fakessn  (default=11)
low-high = '9999'  (prefix='xxx-xx-');
run;&lt;/PRE&gt;
&lt;P&gt;In a picture the string '9999' means that 4 digits will be displayed so if a value is less than 1000 it will be padded with leading 0. The prefix text should be fairly obvious.&lt;/P&gt;
&lt;P&gt;Associate the format with the variable when you want to display it. You would need to make sure the format was available in any SAS session that you want to use this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can run this code after the Proc Format is run to see what the results look like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  do x = 0,1,10,100,1000,4567;
    put x fakessn.;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Look in the log to see the result.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 05:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802737#M316051</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-18T05:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: SSN formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802781#M316075</link>
      <description>The variable is a character and needs to remain that way due to required formats for these data. Mostly 4 digits as in anything less than 1000, I have replaced with ‘xxx-xx-xxxx’ but some remain that are 6 digits or the full 9 digits. I will handle those on an individual basis as there are not many. If I can take ‘1234’ as a character variable and create ‘xxx-xx-1234’ still as a character variable, that would be ideal. Thank you &lt;BR /&gt;</description>
      <pubDate>Fri, 18 Mar 2022 13:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802781#M316075</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-03-18T13:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: SSN formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802821#M316092</link>
      <description>&lt;P&gt;My approach,&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   if length (ssnchar)=4 then newssnchar= put(input(ssnchar,4.),fakessn.));
run;&lt;/PRE&gt;
&lt;P&gt;IF your existing character version is length 11 or greater you could use your existing SSN variable name in place of what I called Newssnchar. I made up names because you did not provide any variable name. It is a good idea whenever discussing character variables to tell us the defined length of the variable as well as names. Sometimes you may be able to place the desired value into an existing variable and otherwise not depending on the length.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 15:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802821#M316092</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-18T15:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: SSN formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802879#M316103</link>
      <description>I checked my code and I previously set the length to 20 to make sure I had room for any longer strings that could be in the data set. Is there any options for this scenario? &lt;BR /&gt;&lt;BR /&gt;Also, fakessn. is not a format I have available. Thank you</description>
      <pubDate>Sat, 19 Mar 2022 00:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802879#M316103</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2022-03-19T00:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: SSN formatting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802880#M316104</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; posted the code for the FAKESSN format earlier in your post.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2022 00:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SSN-formatting/m-p/802880#M316104</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-03-19T00:06:14Z</dc:date>
    </item>
  </channel>
</rss>

