<?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: why my code does nor run as I expected? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/why-my-code-does-nor-run-as-I-expected/m-p/67989#M19459</link>
    <description>First off, || doesn't remove blanks and the new variables are not long enough to store the entire new string.  The catx function might be a better way to go.&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input (var1-var8) ($);&lt;BR /&gt;
cards;&lt;BR /&gt;
a a b b c c d d&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Data test2;&lt;BR /&gt;
set test;&lt;BR /&gt;
length newvar1-newvar4 $20;&lt;BR /&gt;
array intermediate[8] $ var1-var8;&lt;BR /&gt;
array newvar(4) $;&lt;BR /&gt;
array newvarA(4) $;&lt;BR /&gt;
do i=1 to 4;&lt;BR /&gt;
newvar(i)= intermediate[2*i-1]||"/"||intermediate[2*i];&lt;BR /&gt;
newvarA(i)=catx("/",intermediate[2*i-1],intermediate[2*i]);&lt;BR /&gt;
end;&lt;BR /&gt;
keep newvar1-newvar4 newvarA1-newvarA4;&lt;BR /&gt;
run;</description>
    <pubDate>Fri, 20 May 2011 20:31:45 GMT</pubDate>
    <dc:creator>RickM</dc:creator>
    <dc:date>2011-05-20T20:31:45Z</dc:date>
    <item>
      <title>why my code does nor run as I expected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/why-my-code-does-nor-run-as-I-expected/m-p/67988#M19458</link>
      <description>hello all, the following is my code:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input (var1-var8) ($);&lt;BR /&gt;
cards;&lt;BR /&gt;
a a b b c c d d&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Data test2;&lt;BR /&gt;
set test;&lt;BR /&gt;
array intermediate[8] $ var1-var8;&lt;BR /&gt;
array newvar(4) $;&lt;BR /&gt;
	do i=1 to 4;&lt;BR /&gt;
		newvar(i)= intermediate[2*i-1]||"/"||intermediate[2*i];&lt;BR /&gt;
	end;&lt;BR /&gt;
keep newvar1-newvar4;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I am expecting dataset test2 will be:&lt;BR /&gt;
a/a  b/b c/c d/d&lt;BR /&gt;
&lt;BR /&gt;
however, the actual result is:&lt;BR /&gt;
a b c d&lt;BR /&gt;
&lt;BR /&gt;
what mistake have I made?</description>
      <pubDate>Fri, 20 May 2011 20:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/why-my-code-does-nor-run-as-I-expected/m-p/67988#M19458</guid>
      <dc:creator>littlestone</dc:creator>
      <dc:date>2011-05-20T20:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: why my code does nor run as I expected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/why-my-code-does-nor-run-as-I-expected/m-p/67989#M19459</link>
      <description>First off, || doesn't remove blanks and the new variables are not long enough to store the entire new string.  The catx function might be a better way to go.&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input (var1-var8) ($);&lt;BR /&gt;
cards;&lt;BR /&gt;
a a b b c c d d&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Data test2;&lt;BR /&gt;
set test;&lt;BR /&gt;
length newvar1-newvar4 $20;&lt;BR /&gt;
array intermediate[8] $ var1-var8;&lt;BR /&gt;
array newvar(4) $;&lt;BR /&gt;
array newvarA(4) $;&lt;BR /&gt;
do i=1 to 4;&lt;BR /&gt;
newvar(i)= intermediate[2*i-1]||"/"||intermediate[2*i];&lt;BR /&gt;
newvarA(i)=catx("/",intermediate[2*i-1],intermediate[2*i]);&lt;BR /&gt;
end;&lt;BR /&gt;
keep newvar1-newvar4 newvarA1-newvarA4;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 20 May 2011 20:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/why-my-code-does-nor-run-as-I-expected/m-p/67989#M19459</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2011-05-20T20:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: why my code does nor run as I expected?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/why-my-code-does-nor-run-as-I-expected/m-p/67990#M19460</link>
      <description>Thank you very much.</description>
      <pubDate>Fri, 20 May 2011 20:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/why-my-code-does-nor-run-as-I-expected/m-p/67990#M19460</guid>
      <dc:creator>littlestone</dc:creator>
      <dc:date>2011-05-20T20:43:20Z</dc:date>
    </item>
  </channel>
</rss>

