<?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: IF/Then Statement tying multiple rows together in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239977#M44230</link>
    <description>&lt;P&gt;SImplest would be to change the variables to eliminate duplicates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array comment {4};&lt;/P&gt;
&lt;P&gt;do I=1 to 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;do J=i+1 to 4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if comment{I} = comment{J} then comment{J}=' ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then combine them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;result = catx(' ', of comment1-comment4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's not acceptable to replace the original COMMENT variables, copy them to new variables first and work on the new variables to get RESULT.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2015 13:06:50 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-12-18T13:06:50Z</dc:date>
    <item>
      <title>IF/Then Statement tying multiple rows together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239972#M44227</link>
      <description>&lt;P&gt;I transposed data from long to wide and now I need to compare multiple strings (up to four string vars) to determine similitude. I need to concatenate &amp;nbsp;only the unequal strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example:&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; comment1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;comment2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; comment3 &amp;nbsp; &amp;nbsp; &amp;nbsp; Comment4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RESULT&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1001 &amp;nbsp; This is some text &amp;nbsp; This is some text &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; This is some text&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1002 &amp;nbsp; More text like this &amp;nbsp;More text like this&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp; Not the same &amp;nbsp; More text like this &amp;nbsp; More text like this Not the same&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently, only my first if-then is holding, which is "if comment1=comment2 then COMMENT=comment1". I'll spare you the rest, because it's not pretty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 12:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239972#M44227</guid>
      <dc:creator>UMAnalyst</dc:creator>
      <dc:date>2015-12-18T12:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: IF/Then Statement tying multiple rows together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239977#M44230</link>
      <description>&lt;P&gt;SImplest would be to change the variables to eliminate duplicates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array comment {4};&lt;/P&gt;
&lt;P&gt;do I=1 to 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;do J=i+1 to 4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if comment{I} = comment{J} then comment{J}=' ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then combine them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;result = catx(' ', of comment1-comment4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's not acceptable to replace the original COMMENT variables, copy them to new variables first and work on the new variables to get RESULT.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 13:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239977#M44230</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-18T13:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: IF/Then Statement tying multiple rows together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239989#M44232</link>
      <description>&lt;P&gt;Thank you. It's scary to delete stuff, but that's why we have backups.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 13:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239989#M44232</guid>
      <dc:creator>UMAnalyst</dc:creator>
      <dc:date>2015-12-18T13:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: IF/Then Statement tying multiple rows together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239996#M44235</link>
      <description>&lt;P&gt;Why transpose the data in the first place to to this, then code around the fact that its transposed? &amp;nbsp;Just do your logic on the normalised data.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 13:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239996#M44235</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-18T13:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: IF/Then Statement tying multiple rows together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239999#M44236</link>
      <description>you can continue  comment1=comment2 and &lt;BR /&gt;comment3=comment4 and so on.. as you have only 4 Variables and  if  you do not  understand Do Loops.How ever DL is  actually a permanent solution</description>
      <pubDate>Fri, 18 Dec 2015 13:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/239999#M44236</guid>
      <dc:creator>pearsoninst</dc:creator>
      <dc:date>2015-12-18T13:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: IF/Then Statement tying multiple rows together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/240003#M44237</link>
      <description>&lt;P&gt;I transposed because I need to get from multiple rows per respondent to one row per respondent.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 13:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/240003#M44237</guid>
      <dc:creator>UMAnalyst</dc:creator>
      <dc:date>2015-12-18T13:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: IF/Then Statement tying multiple rows together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/240014#M44239</link>
      <description>&lt;P&gt;Perhaps you misunderstand, you can process the data either in long or wide format, it makes no difference. &amp;nbsp;Personally I would use transposed data only for reporting purposes (apart from a few times). &amp;nbsp;Its just simpler working with normalised data&amp;amp;colon;&lt;/P&gt;
&lt;PRE&gt;data have;
  length comment $50;
  id=1; 
  comment="This is some text"; output;
  comment="This is some text"; output;
  comment=""; output;
  comment="This is some text"; output;
  id=2; 
  comment="More text like this"; output;
  comment="More text like this"; output;
  comment="Not the same"; output;
  comment="More text like this"; output;
run;

proc sort data=have nodupkey;
  by id comment;
run;

data want (keep=id result);
  set have;
  by id;
  retain result;
  length result $2000;
  if first.id then result="";
  result=catx(" ",result,comment);
  if last.id then output;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Dec 2015 14:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/240014#M44239</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-18T14:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: IF/Then Statement tying multiple rows together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/240056#M44252</link>
      <description>&lt;P&gt;Great idea. Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 17:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Then-Statement-tying-multiple-rows-together/m-p/240056#M44252</guid>
      <dc:creator>UMAnalyst</dc:creator>
      <dc:date>2015-12-18T17:15:42Z</dc:date>
    </item>
  </channel>
</rss>

