<?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: Concat all variables including missing values: cats(of _all_) does not work with missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831117#M328432</link>
    <description>&lt;P&gt;You need to tell the data step compiler that you want the concat variable(s) to be character strings.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
  input x1-x5;
  length concat1-concat3 $30 ;
  Concat1 = cats(of _all_);
  Concat2 = cats(of X1-X5);
  Concat3 = cats(of X1--X5);
datalines;
1 2 3 4 5
. 2 . 4 5
. . . . .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    x1    x2    x3    x4    x5    concat1    concat2    concat3

 1      1     2     3     4     5     12345      12345      12345
 2      .     2     .     4     5     .2.45      .2.45      .2.45
 3      .     .     .     .     .     .....      .....      .....

&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Aug 2022 16:28:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-08-30T16:28:21Z</dc:date>
    <item>
      <title>Concat all variables including missing values: cats(of _all_) does not work with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831050#M328398</link>
      <description>&lt;P&gt;I want to check if all variables of a data set are missing except one, but without knowledge about the variable names. (I import some excel files of different structure and want to get rid of all the rows with only missing values, except there is a column with the row number that will be non missing.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my first idea was to concatenate all the (maybe missing) values and then check this value, but the concatenation using 'cats(of _all_)' does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data x;
input x1 x2 x3 x4 x5;&lt;BR /&gt;Concat = cats(of _all_);&lt;BR /&gt;*Concat = cats(of X1-X5);&lt;BR /&gt;*Concat = cats(of X1--X5);
datalines;
1 2 3 4 5
. 2 . 4 5
. . . . .
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;x1	x2	x3	x4	x5	Concat
1	2	3	4	5	12345
.	2	.	4	5	.
.	.	.	.	.	.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The versions with 'cats(of X1-X5)' and 'cats(of X1--X5)' are working as expected, but as mentioned I do not want to determine any knowledge about the variable names at this point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any help on this.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 09:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831050#M328398</guid>
      <dc:creator>Martin_Trinks</dc:creator>
      <dc:date>2022-08-30T09:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Concat all variables including missing values: cats(of _all_) does not work with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831116#M328431</link>
      <description>What values are you expecting to see in Concat in the other two rows?</description>
      <pubDate>Tue, 30 Aug 2022 16:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831116#M328431</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2022-08-30T16:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Concat all variables including missing values: cats(of _all_) does not work with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831117#M328432</link>
      <description>&lt;P&gt;You need to tell the data step compiler that you want the concat variable(s) to be character strings.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
  input x1-x5;
  length concat1-concat3 $30 ;
  Concat1 = cats(of _all_);
  Concat2 = cats(of X1-X5);
  Concat3 = cats(of X1--X5);
datalines;
1 2 3 4 5
. 2 . 4 5
. . . . .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    x1    x2    x3    x4    x5    concat1    concat2    concat3

 1      1     2     3     4     5     12345      12345      12345
 2      .     2     .     4     5     .2.45      .2.45      .2.45
 3      .     .     .     .     .     .....      .....      .....

&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2022 16:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831117#M328432</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-30T16:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Concat all variables including missing values: cats(of _all_) does not work with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831127#M328435</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I want to check if all variables of a data set are missing except one, but without knowledge about the variable names.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Use the CMISS() function to count number of missing.&amp;nbsp; You will need to know how many variables there are to get your test of "except one".&amp;nbsp; Here is a trick to dynamically count the variables in a datastep by making two arrays.&amp;nbsp; You will need to introduce an extra character variable to make sure it works for datasets with zero character variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
  input x1 x2 x3 x4 x5;
  nmiss=cmiss(of _all_)-1;
  array _n _numeric_;
  array _c $1 _c_ _character_;
  drop _c_ ;
  nvars = dim(_n) + dim(_c) -2 ;
  except1 = 1 = (nvars - nmiss);
datalines;
1 2 3 4 5
. 2 . 4 5
1 2 3 4 .
1 . . . .
. . . . .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;It might be easier to just add an extra step that finds the number of variables and puts it into a macro variable instead.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
  input x1 x2 x3 x4 x5;
datalines;
1 2 3 4 5
. 2 . 4 5
1 2 3 4 .
1 . . . .
. . . . .
;

proc sql noprint;
  select count(*) into :nvars trimmed
  from dictionary.columns
  where libname='WORK' and memname='X'
  ;
quit;
data want;
  set x;
  nmiss=cmiss(of _all_)-1;
  except1 = 1 = (&amp;amp;nvars - nmiss);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 16:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-all-variables-including-missing-values-cats-of-all-does/m-p/831127#M328435</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-30T16:48:01Z</dc:date>
    </item>
  </channel>
</rss>

