<?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: Data Manipulation Question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595589#M171377</link>
    <description>&lt;P&gt;Hi Thanks , I have tested the catx solution and it works ..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to know if this could be done with arrays and hence i had asked the question &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; ..&lt;/P&gt;
&lt;P&gt;If it's too much of a bother please ignore my reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But many thanks to all for the quick turn around&lt;/P&gt;</description>
    <pubDate>Thu, 10 Oct 2019 23:28:19 GMT</pubDate>
    <dc:creator>dennis_oz</dc:creator>
    <dc:date>2019-10-10T23:28:19Z</dc:date>
    <item>
      <title>Data Manipulation Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595576#M171369</link>
      <description>&lt;P&gt;Hi All, I have 5 variables as below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Street_number&lt;/P&gt;
&lt;P&gt;Street_name&lt;/P&gt;
&lt;P&gt;Street_type&lt;/P&gt;
&lt;P&gt;Suburb&lt;/P&gt;
&lt;P&gt;Postcode&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have writte a logic that checks if any of the variable names are&amp;nbsp; empty and then I concat the remaining fields that are not empty.&lt;/P&gt;
&lt;P&gt;For that I have written multiple IF then logic's. Can I simplify the code like do this in a loop and reduce the IF Then's ?&lt;/P&gt;
&lt;P&gt;********************************************************************&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If street_number&amp;nbsp;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; eq ' '&lt;/FONT&gt;&lt;/STRONG&gt; and street_name not in&amp;nbsp; ' '&amp;nbsp; and street_type not in ( ' ') and suburb not in&amp;nbsp; ' ' and postcode not in&amp;nbsp;&amp;nbsp; ' ' then&lt;/P&gt;
&lt;P&gt;Siteadd =&amp;nbsp; trim(street_name) || ' ' || trim(street_type) ||' ' || trim(suburb ) || ' ' ||&amp;nbsp; trim(postcode )&lt;/P&gt;
&lt;P&gt;Else if&amp;nbsp;&lt;/P&gt;
&lt;P&gt;street_number&amp;nbsp; &lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;eq ' '&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt; and street_name&amp;nbsp;&lt;FONT color="#000000"&gt;&lt;STRONG&gt; in (' ')&lt;/STRONG&gt;&lt;/FONT&gt; and street_type not in ( ' ') and suburb not in (' ') and postcode not in&amp;nbsp; (' ')&lt;/P&gt;
&lt;P&gt;Then&lt;/P&gt;
&lt;P&gt;Siteadd =&amp;nbsp; &amp;nbsp;trim(street_type)|| ' '|| trim(suburb ) || ' ' ||&amp;nbsp; trim(postcode )&lt;/P&gt;
&lt;P&gt;else if&amp;nbsp;street_number&amp;nbsp;&lt;FONT color="#000000"&gt;&lt;STRONG&gt; eq ' '&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt; and street_name&amp;nbsp; &lt;FONT color="#000000"&gt;&lt;STRONG&gt;in (' ') &lt;/STRONG&gt;&lt;/FONT&gt;and street_type not in ( ' ') and suburb not in (' ') and postcode &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;in (' ')&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;then siteadd= trim(street_type) ||&amp;nbsp; suburb;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 22:10:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595576#M171369</guid>
      <dc:creator>dennis_oz</dc:creator>
      <dc:date>2019-10-10T22:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulation Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595580#M171373</link>
      <description>&lt;P&gt;You need to use the CATX function. It takes care of missing values.&lt;/P&gt;
&lt;PRE&gt;SITE ADD= catx(' '
              ,Street_number
              ,Street_name
              ,Street_type
              ,Suburb
              ,Postcode);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 22:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595580#M171373</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-10-10T22:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulation Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595583#M171374</link>
      <description>&lt;P&gt;thanks for the reply .. I will test your solution..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please suggest how I can do this using arrays&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for example :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and loop through&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Array Adress_variables(*) Stnum stname sttype Suburb postcode&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 22:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595583#M171374</guid>
      <dc:creator>dennis_oz</dc:creator>
      <dc:date>2019-10-10T22:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulation Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595584#M171375</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19264"&gt;@dennis_oz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no need for looping when using CATX(). May be read up in the documentation what this function provides.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use an array name instead of spelling out all the variables using syntax like:&lt;/P&gt;
&lt;P&gt;catx(of myarray[*])&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 22:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595584#M171375</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-10T22:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulation Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595589#M171377</link>
      <description>&lt;P&gt;Hi Thanks , I have tested the catx solution and it works ..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to know if this could be done with arrays and hence i had asked the question &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; ..&lt;/P&gt;
&lt;P&gt;If it's too much of a bother please ignore my reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But many thanks to all for the quick turn around&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 23:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595589#M171377</guid>
      <dc:creator>dennis_oz</dc:creator>
      <dc:date>2019-10-10T23:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulation Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595602#M171386</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19264"&gt;@dennis_oz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using catx() is just so much simpler. But here populating&amp;nbsp;&lt;CODE class=" language-sas"&gt;addr_comb_2&lt;/CODE&gt;&amp;nbsp;the way you could have done it in the old days before the strip() and catx() function got introduced.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  Street_number='Street_number';
  Street_name='Street_name';
  Street_type='      ';
  Suburb='Suburb';
  Postcode='Postcode';
  output;
  stop;
run;

data want(drop=_:);
  set have;
  length addr_comb_1 addr_comb_2 $200;
  array addrvars {*} Street_number Street_name Street_type Suburb Postcode;
  addr_comb_1=catx(' ', of addrvars [*]);
  do _i=1 to dim(addrvars);
    if addrvars[_i] ne ' ' then 
      addr_comb_2=trim(left(addr_comb_2))||' '||left(addrvars[_i]);
  end;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 00:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595602#M171386</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-11T00:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Data Manipulation Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595619#M171390</link>
      <description>&lt;P&gt;Did you see this reply?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;SITEADD= catx( of MAYARRAY[*] );&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 02:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Manipulation-Question/m-p/595619#M171390</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-10-11T02:59:45Z</dc:date>
    </item>
  </channel>
</rss>

