<?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: Why the result useing the catx have blanks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561045#M157002</link>
    <description>&lt;P&gt;thanks&lt;/P&gt;</description>
    <pubDate>Thu, 23 May 2019 05:51:19 GMT</pubDate>
    <dc:creator>HannaZhang</dc:creator>
    <dc:date>2019-05-23T05:51:19Z</dc:date>
    <item>
      <title>Why the result useing the catx have blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561030#M156995</link>
      <description>&lt;P&gt;HI,all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;the question is “Why I use the catx function couldn not get the results as use the symbol "||&lt;/SPAN&gt;" which is without blank between two&amp;nbsp;&lt;SPAN&gt;variables"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;THANKS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*the &lt;SPAN&gt;variable "aestart"&amp;nbsp; is uesd code as follows:*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if ^missing(aestdat) then do&lt;BR /&gt;aestart=put(aestdat,yymmdd10.)||"T"||aesttim;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/*the variable "aa"&amp;nbsp; by using the catx function:*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;aa=catx("",aestart1,"T",aesttim);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the results as follow&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 353px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29718iF1332E71AD9DA5AD/image-dimensions/353x513?v=v2" width="353" height="513" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 04:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561030#M156995</guid>
      <dc:creator>HannaZhang</dc:creator>
      <dc:date>2019-05-23T04:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why the result useing the catx have blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561034#M156996</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The CATX function first copies &lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;item-1&lt;/SPAN&gt;&lt;SPAN&gt; to the result, &lt;STRONG&gt;omitting leading and trailing blanks&lt;/STRONG&gt;. Next, for each subsequent argument &lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;item-i&lt;/SPAN&gt;&lt;SPAN&gt;, i=2, …, n, if &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;item-i&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt; contains at least one non-blank character&lt;/STRONG&gt;, CATX appends &lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;delimiter&lt;/SPAN&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;item-i&lt;/SPAN&gt;&lt;SPAN&gt; to the result, &lt;STRONG&gt;omitting leading and trailing blanks from &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;item-i&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;. CATX does not insert the delimiter at the beginning or end of the result. Blank items do not produce delimiters at the beginning or end of the result, &lt;STRONG&gt;nor do blank items produce multiple consecutive delimiters.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that clarify it for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you've used CATX incorrectly though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The delimiter is supposed to be the FIRST parameter, not the third. I think you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;aa = catx("T", aestart1, aesttim);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or alternatively use the CATT function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;aa = catt(aestart1, "T", aesttim);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/275211"&gt;@HannaZhang&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;HI,all&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;the question is “Why I use the catx function couldn not get the results as use the symbol "||&lt;/SPAN&gt;" which is without blank between two&amp;nbsp;&lt;SPAN&gt;variables"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;THANKS.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*the &lt;SPAN&gt;variable "aestart"&amp;nbsp; is uesd code as follows:*/&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if ^missing(aestdat) then do&lt;BR /&gt;aestart=put(aestdat,yymmdd10.)||"T"||aesttim;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;/*the variable "aa"&amp;nbsp; by using the catx function:*/&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;aa=catx("",aestart1,"T",aesttim);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the results as follow&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 353px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29718iF1332E71AD9DA5AD/image-dimensions/353x513?v=v2" width="353" height="513" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 04:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561034#M156996</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-23T04:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why the result useing the catx have blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561036#M156997</link>
      <description>&lt;P&gt;Convert your separate date and time into a datetime column, then use the appropriate format, instead of trying to roll your own:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   date=date();
   time=time();
   format date date. time time.;
run;

data want;
   set have;
   datetime=dhms(date,0,0,time);
   datetime2=datetime;
   format datetime datetime.;
   format datetime2 e8601dt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you REALLY want to do what you're trying:&amp;nbsp; 1) read the doc on the CATX function, and 2) use the CATS function instead, or 3) use CATX("T",date,time).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But IMO you should store dates as dates, times as times, and datetimes as datetimes, instead of character string representations of your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 04:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561036#M156997</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-05-23T04:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why the result useing the catx have blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561037#M156998</link>
      <description>&lt;P&gt;And...&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;is correct, you should be storing your date time as a SAS date time variable not as a character variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would recommend the following code instead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;aa =dhms(input(
                substr(aestart1, 1, 10), yymmdd10.)
                ), 
         0, 
         0, 
         input(
               coalesce(aesttim, 0), time.)
               )
         );

format aa datetime20.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 May 2019 04:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561037#M156998</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-23T04:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why the result useing the catx have blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561042#M157000</link>
      <description>Hi,ScottBass,&lt;BR /&gt;Thanks for your solution&amp;nbsp; to&amp;nbsp; my question ,It really helped me solve the problem.By the way, thanks for your suggestion to my post.</description>
      <pubDate>Thu, 23 May 2019 05:34:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561042#M157000</guid>
      <dc:creator>HannaZhang</dc:creator>
      <dc:date>2019-05-23T05:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why the result useing the catx have blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561044#M157001</link>
      <description>&lt;P&gt;You've stumbled across a peculiarity of SAS when it comes to "empty" strings. Missing character variables are padded with strings, and SAS inserts single blanks as delimiters (eg when you put variables with the put statement) if no other delimiter is explicitly specified.&lt;/P&gt;
&lt;P&gt;In your case, by using an empty string as the first parameter in catx, you have made SAS insert single blanks.&lt;/P&gt;
&lt;P&gt;You should have used either&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;aa = catx("T",aestart1,aesttim);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;aa = cats(aestart1,"T",aesttim);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to avoid these blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The really correct method is, of course, to use SAS date and time values and the formats that SAS provides for such values, as is done in the accepted solution.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 05:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561044#M157001</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-23T05:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why the result useing the catx have blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561045#M157002</link>
      <description>&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 05:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561045#M157002</guid>
      <dc:creator>HannaZhang</dc:creator>
      <dc:date>2019-05-23T05:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Why the result useing the catx have blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561046#M157003</link>
      <description>&lt;P&gt;Thanks a lot,I think I know what my &lt;SPAN&gt;Mental flaw&lt;/SPAN&gt; is.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 05:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-the-result-useing-the-catx-have-blanks/m-p/561046#M157003</guid>
      <dc:creator>HannaZhang</dc:creator>
      <dc:date>2019-05-23T05:54:10Z</dc:date>
    </item>
  </channel>
</rss>

