<?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: A space inside the concatenated variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848983#M335668</link>
    <description>Trailing blanks are already part of DEPT.  Try a tool that removes leading and trailing blanks:&lt;BR /&gt;&lt;BR /&gt;assignment = cats(dept, site);</description>
    <pubDate>Sun, 11 Dec 2022 12:28:13 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2022-12-11T12:28:13Z</dc:date>
    <item>
      <title>A space inside the concatenated variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848977#M335667</link>
      <description>&lt;PRE&gt;data temp2;
	set spg.temp (keep=dept site);
Assignment = dept||put(site,2.);
run;
proc print data=temp2;run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nietzsche_0-1670755922408.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78298i9E50595FCD27F89F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Nietzsche_0-1670755922408.png" alt="Nietzsche_0-1670755922408.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hello, just wondering why is there a space inside the concatenated variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 10:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848977#M335667</guid>
      <dc:creator>Nietzsche</dc:creator>
      <dc:date>2022-12-11T10:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: A space inside the concatenated variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848983#M335668</link>
      <description>Trailing blanks are already part of DEPT.  Try a tool that removes leading and trailing blanks:&lt;BR /&gt;&lt;BR /&gt;assignment = cats(dept, site);</description>
      <pubDate>Sun, 11 Dec 2022 12:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848983#M335668</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-12-11T12:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: A space inside the concatenated variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848987#M335669</link>
      <description>&lt;P&gt;Also see Maxim 46.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 13:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848987#M335669</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-11T13:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: A space inside the concatenated variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848989#M335670</link>
      <description>&lt;P&gt;The space is inside the variable because you specified the format when creating the variable (put(site,2.)). This specifies that the variable should have a length of two, and the space will be included in this length. To remove the space, you can reduce the format to 1. instead of 2.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 14:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/848989#M335670</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2022-12-11T14:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: A space inside the concatenated variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/849003#M335674</link>
      <description>&lt;P&gt;SAS only has two types of variables. Floating point numbers and fixed length character strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DEPT variable must be defined as longer than 4 bytes or else there would not be any spaces after the values 'PURH' and 'PERS'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The ODS output results typically use proportional fonts and other changes that make seeing spaces hard.&lt;/P&gt;
&lt;P&gt;If you look at the values using fixed width font then it will be clearer what is going on as the append digits will all appear in the same character position.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not want to include the spaces used to fill out the fixed length variable then modify your code to remove them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Assignment = trim(dept)||put(site,2.);
Assignment = cats(dept,site);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also note that if SITE is less than &amp;lt;10 then the PUT() function will also introduce a space.&amp;nbsp; You could use Z2. format instead and get strings like 08.&amp;nbsp; Or use the -L format modifier to left align the digits. So '8 ' instead of ' 8'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 16:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/849003#M335674</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-11T16:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: A space inside the concatenated variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/849044#M335689</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192091"&gt;@ger15xxhcker&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The space is inside the variable because you specified the format when creating the variable (put(site,2.)). This specifies that the variable should have a length of two, and the space will be included in this length. To remove the space, you can reduce the format to 1. instead of 2.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry, but this is completely wrong. The blanks are part of dept and the html-output collapses the blanks automatically. Here is the log-output of an extended version of the program displaying all blanks:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 81         data temp2;
 82            set sasuser.temp (keep=dept site);
 83            dept = translate(dept, '#', ' ');
 84            Assignment = dept||put(site,2.);
 85            put Assignment=;
 86         run;
 
 Assignment=DP###26
 Assignment=PURH#57
 Assignment=PERS#34
 Assignment=BK###57
 Assignment=DP###95
 Assignment=BK###44
 Assignment=DP###59
 Assignment=PUB##38
 Assignment=DP###44
 Assignment=DP###90&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Dec 2022 07:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/849044#M335689</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-12-12T07:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: A space inside the concatenated variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/849045#M335690</link>
      <description>&lt;P&gt;Below two ways how to do this. If using cats() - most people would - make sure that you define the length of the assignment variable beforehand as else it will default to a length of $200.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  length dept $4 site 8 assignment_1 assignment_1 $6;
  dept='ABC';
  site=5;
  assignment_1=strip(dept)||put(site,2. -l);
  assignment_2=cats(dept,put(site,2.));
run;

proc print data=sample;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Dec 2022 07:41:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-space-inside-the-concatenated-variable/m-p/849045#M335690</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-12-12T07:41:09Z</dc:date>
    </item>
  </channel>
</rss>

