<?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 replace spaces with &amp;quot;-&amp;quot; within a variable? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695719#M25195</link>
    <description>Rohana-&lt;BR /&gt;Can you copy and paste the text of the code in a reply? This isn't legible when I zoom.&lt;BR /&gt;Thanks!</description>
    <pubDate>Sun, 01 Nov 2020 05:44:27 GMT</pubDate>
    <dc:creator>dthompsonada</dc:creator>
    <dc:date>2020-11-01T05:44:27Z</dc:date>
    <item>
      <title>How to replace spaces with "-" within a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695337#M25174</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to figure out how to replace the spaces within the Init variable with dashes ("-"). I've already compressed the variable to remove the periods from the raw data (3rd pic below), but just need the final initial format to be in FML or F-L if missing data. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 15:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695337#M25174</guid>
      <dc:creator>RohanaBruker</dc:creator>
      <dc:date>2020-12-10T15:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace spaces with "-" within a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695344#M25175</link>
      <description>You know there's an SSN format?&lt;BR /&gt;If your variable is numeric you can apply the format directly to get the desired displayed value.&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?cdcId=vdmmlcdc&amp;amp;cdcVersion=1.0&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=n1sroiq0fqlgncn1d52g0go5xqeq.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=vdmmlcdc&amp;amp;cdcVersion=1.0&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=n1sroiq0fqlgncn1d52g0go5xqeq.htm&amp;amp;locale=en&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The process for INITS is similar to what you've done with SSN, but you can use COUNTC() or LENGHT to count the number of periods/letters to deal with the two versus three letter cases.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;inits_new = compress(inits);&lt;BR /&gt;if length(inits_new) = 2 then inits_new = catx('-', char(inits_new, 1), char(inits_new, 2));&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Oct 2020 20:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695344#M25175</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-29T20:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace spaces with "-" within a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695719#M25195</link>
      <description>Rohana-&lt;BR /&gt;Can you copy and paste the text of the code in a reply? This isn't legible when I zoom.&lt;BR /&gt;Thanks!</description>
      <pubDate>Sun, 01 Nov 2020 05:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695719#M25195</guid>
      <dc:creator>dthompsonada</dc:creator>
      <dc:date>2020-11-01T05:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace spaces with "-" within a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695748#M25198</link>
      <description>&lt;P&gt;The TRANSLATE() function is for replacing characters with other characters. Watch out for two things. Remember to trim the trailing blanks from your variable's value.&amp;nbsp; And the arguments for TRANSLATE() are in the opposite order of what you normally expect.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  myvar = translate(trim(myvar),'-',' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS Please post text as text, not as photographs.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 15:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-replace-spaces-with-quot-quot-within-a-variable/m-p/695748#M25198</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-01T15:42:41Z</dc:date>
    </item>
  </channel>
</rss>

