<?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: CATX but don't skip blanks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906757#M358032</link>
    <description>Wow, that worked.. I'll have to learn how you did that with "separated by". Thanks!</description>
    <pubDate>Thu, 07 Dec 2023 17:27:42 GMT</pubDate>
    <dc:creator>EdCenter</dc:creator>
    <dc:date>2023-12-07T17:27:42Z</dc:date>
    <item>
      <title>CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906573#M357955</link>
      <description>&lt;P&gt;I have a table with fields that are mixed numeric and character, and some of the fields are blank. I'm trying to CATX them with a '|' delimiter so that I can output it to a CSV file, but CATX is skipping blank fields. Is there a way around this? Below is a sample code of what I'm trying to do, but instead of axyz = "1|a|c", I want it to be "1|a||c" (extra | between a and c). Is there a way to do this without brute forcing it using CATS and listing every column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;data my_data;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&amp;nbsp; &amp;nbsp; input a x $ y $ z $;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&amp;nbsp; &amp;nbsp; datalines;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;1 a . c&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;run;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;data new_my_data;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;set my_data;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;length axyz $16;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;axyz = catx('|', of a--z);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;run;&lt;/DIV&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>Wed, 06 Dec 2023 18:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906573#M357955</guid>
      <dc:creator>EdCenter</dc:creator>
      <dc:date>2023-12-06T18:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906582#M357960</link>
      <description>&lt;P&gt;If you don't require using cat.. function, concatenation operator '||' could do this job;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set my_data;
	axyz= a||'|'||x||'|'||y||'|'||z;
proc print;run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 19:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906582#M357960</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-12-06T19:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906589#M357961</link>
      <description>Thanks, so yes this is one option but I would have to apply to several tables with different column names.&lt;BR /&gt;So is there a way to use the "a--z" functionality in SAS to concat all of these fields?</description>
      <pubDate>Wed, 06 Dec 2023 19:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906589#M357961</guid>
      <dc:creator>EdCenter</dc:creator>
      <dc:date>2023-12-06T19:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906592#M357964</link>
      <description>&lt;P&gt;What about using PROC EXPORT to create your CSV using "|" as the delimiter?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 19:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906592#M357964</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-12-06T19:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906595#M357966</link>
      <description>Heh, so the wrinkle is that I have different tables with different columns that I have to interleave to create a single pseudo-EDI file for processing.&lt;BR /&gt;&lt;BR /&gt;So for simplicity, I have 4 tables: Header, Member, Detail, Trailer table. Each with different columns. I need to interleave it like this:&lt;BR /&gt;Header&lt;BR /&gt;Member(1)&lt;BR /&gt;Detail(1)&lt;BR /&gt;...&lt;BR /&gt;Member(n)&lt;BR /&gt;Detail(n)&lt;BR /&gt;Trailer&lt;BR /&gt;&lt;BR /&gt;What I'm trying to do with CATX is to concat everything into a single field, then interleave the records in each table (in the right order) into a flatfile.</description>
      <pubDate>Wed, 06 Dec 2023 19:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906595#M357966</guid>
      <dc:creator>EdCenter</dc:creator>
      <dc:date>2023-12-06T19:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906597#M357967</link>
      <description>&lt;P&gt;Then I would replace missing values with a rare special character (during concatenation using cat..) to replace them later by a missing value again using tranwrd function like below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set my_data;
	array vars [*] a--z;
	do i=1 to dim(vars);
		if vars{i}='' then vars{i}= '~';
	end; 

	axyz= catx('|', of a--z);
	if find(axyz, '~') gt 0 then axyz= tranwrd(axyz, '~', ' '); 

	do i= 1 to dim(vars);
		if vars{i}='~' then vars{i}= '';
	end; 
    drop i; 
proc print;run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2023 19:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906597#M357967</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-12-06T19:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906604#M357970</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/460545"&gt;@EdCenter&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Heh, so the wrinkle is that I have different tables with different columns that I have to interleave to create a single pseudo-EDI file for processing.&lt;BR /&gt;&lt;BR /&gt;So for simplicity, I have 4 tables: Header, Member, Detail, Trailer table. Each with different columns. I need to interleave it like this:&lt;BR /&gt;Header&lt;BR /&gt;Member(1)&lt;BR /&gt;Detail(1)&lt;BR /&gt;...&lt;BR /&gt;Member(n)&lt;BR /&gt;Detail(n)&lt;BR /&gt;Trailer&lt;BR /&gt;&lt;BR /&gt;What I'm trying to do with CATX is to concat everything into a single field, then interleave the records in each table (in the right order) into a flatfile.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This looks like basic report writing.&amp;nbsp; Use BY group processing;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file out dsd ;
  set have end=eof;
  by member ;
  if _n_=1 then put header;
  if first.member then put member;
  put details;
  if eof then put trailer;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;128  data _null_;
129    set class end=eof;
130    by sex;
131    file log dsd dlm='|';
132    if _n_=1 then put 'Report of SASHELP.CLASS by SEX';
133    if first.sex then put sex;
134    put name -- weight;
135    if eof then put 'End of Report';
136  run;

Report of SASHELP.CLASS by SEX
F
Alice|F|13|56.5|84
Barbara|F|13|65.3|98
Carol|F|14|62.8|102.5
Jane|F|12|59.8|84.5
Janet|F|15|62.5|112.5
Joyce|F|11|51.3|50.5
Judy|F|14|64.3|90
Louise|F|12|56.3|77
Mary|F|15|66.5|112
M
Alfred|M|14|69|112.5
Henry|M|14|63.5|102.5
James|M|12|57.3|83
Jeffrey|M|13|62.5|84
John|M|12|59|99.5
Philip|M|16|72|150
Robert|M|12|64.8|128
Ronald|M|15|67|133
Thomas|M|11|57.5|85
William|M|15|66.5|112
End of Report
&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2023 21:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906604#M357970</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-06T21:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906606#M357971</link>
      <description>&lt;P&gt;Use the reverse of the INFILE trick. Call it the FILE trick.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dummy temp;
data want;
 set sashelp.class;
 length line $100;
 file dummy dsd dlm='|' ;
 put @1 100*' ' @1 name--weight @;
 line=_file_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2023 20:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906606#M357971</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-06T20:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906609#M357973</link>
      <description>&lt;P&gt;Yes this is my other option. Change all blanks to "." and ask the development team to ignore fields with just ".". Was hoping to avoid this option.&lt;BR /&gt;&lt;BR /&gt;As for the use of arrays, not all columns are string which is the other issue with the use of arrays (which I looked into).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 20:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906609#M357973</guid>
      <dc:creator>EdCenter</dc:creator>
      <dc:date>2023-12-06T20:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906612#M357974</link>
      <description>Never seen _FILE_ before.. It looks like it might help. Thanks, I think the solution is to use PUT &amp;amp; @. Let me work with your sample and see if I can make it work..</description>
      <pubDate>Wed, 06 Dec 2023 20:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906612#M357974</guid>
      <dc:creator>EdCenter</dc:creator>
      <dc:date>2023-12-06T20:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906620#M357981</link>
      <description>&lt;P&gt;even more "lazy" version &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dummy temp;
data want;
 set sashelp.class;
 file dummy dsd dlm='|' ;
 put @1 100*' ' @1 (_all_) (:) @;

 length line $100;
 line=_file_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 21:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906620#M357981</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-12-06T21:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906651#M357995</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data my_data;
    input a x $ y $ z $;
    datalines;
1 a . c
;
run;

proc transpose data=my_data(obs=0) out=temp;
var _all_;
run;
proc sql noprint;
select cats('strip(',_name_,')') into :catx separated by '||"|"||'  from temp ;
quit; 
data new_my_data;
set my_data;
length axyz $ 200;
axyz = &amp;amp;catx.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1701927837292.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90925i0FE79FFA676D6501/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1701927837292.png" alt="Ksharp_0-1701927837292.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 05:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906651#M357995</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-12-07T05:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: CATX but don't skip blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906757#M358032</link>
      <description>Wow, that worked.. I'll have to learn how you did that with "separated by". Thanks!</description>
      <pubDate>Thu, 07 Dec 2023 17:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-but-don-t-skip-blanks/m-p/906757#M358032</guid>
      <dc:creator>EdCenter</dc:creator>
      <dc:date>2023-12-07T17:27:42Z</dc:date>
    </item>
  </channel>
</rss>

