<?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: Coalesce to collapse variables not working and takes a lot of time in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Coalesce-to-collapse-variables-not-working-and-takes-a-lot-of/m-p/930513#M41844</link>
    <description>&lt;P&gt;Something like below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  index = whichc('1',city,school,parents) &amp;gt; 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bit weird that variables only containing zero and one are of type character with a length of $20&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jun 2024 11:08:52 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-06-01T11:08:52Z</dc:date>
    <item>
      <title>Coalesce to collapse variables not working and takes a lot of time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coalesce-to-collapse-variables-not-working-and-takes-a-lot-of/m-p/930511#M41842</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;suppose to have the following dataset:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$20. City :$20. School :$20. Parents :$20.;
cards;
0001 0   0   0
0001 1   1   1
0004 1   0   0
0004 0   0   1
0004 0   0   0
0005 0   1   1
0006 1   0   0
0006 1   1   1
0006 1   1   0
....
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;I'm trying to merge all the variables to get the following:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB1;
  input ID :$20. Index :$20.;
cards;
0001 0
0001 1
0004 1
0004 1
0004 0
0005 1
0006 1
0006 1
0006 1
....
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The rule is: if there is at least one "1" in "City", "School", "Parents" then Index = 1 otherwise 0. I tried to use coalesce but it takes a lot of time because the variables to be collapsed are 10 but the rows are 30.000. Is there an alternative to do the job?&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 10:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coalesce-to-collapse-variables-not-working-and-takes-a-lot-of/m-p/930511#M41842</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-06-01T10:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce to collapse variables not working and takes a lot of time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coalesce-to-collapse-variables-not-working-and-takes-a-lot-of/m-p/930512#M41843</link>
      <description>&lt;P&gt;why not use this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB(KEEP=ID index);
  input ID :$20. City :$20. School :$20. Parents :$20.;
  
  &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;index = max(city,school,parents);&lt;/STRONG&gt;&lt;/FONT&gt;
cards;
0001 0   0   0
0001 1   1   1
0004 1   0   0
0004 0   0   1
0004 0   0   0
0005 0   1   1
0006 1   0   0
0006 1   1   1
0006 1   1   0
....
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jun 2024 11:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coalesce-to-collapse-variables-not-working-and-takes-a-lot-of/m-p/930512#M41843</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2024-06-01T11:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesce to collapse variables not working and takes a lot of time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Coalesce-to-collapse-variables-not-working-and-takes-a-lot-of/m-p/930513#M41844</link>
      <description>&lt;P&gt;Something like below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  index = whichc('1',city,school,parents) &amp;gt; 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bit weird that variables only containing zero and one are of type character with a length of $20&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 11:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Coalesce-to-collapse-variables-not-working-and-takes-a-lot-of/m-p/930513#M41844</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-06-01T11:08:52Z</dc:date>
    </item>
  </channel>
</rss>

