<?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: How to combine two arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468774#M285483</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203676"&gt;@liyongkai800&lt;/a&gt;&amp;nbsp;You wrote&amp;nbsp;&lt;EM&gt;"Is there easier way that I don't have to change the name one by one? Thanks."&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you had a chance to look at my previous response. I believe that does exactly what you are looking for. Please correct me if i am wrong&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jun 2018 16:23:31 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-06-08T16:23:31Z</dc:date>
    <item>
      <title>How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468742#M285475</link>
      <description>&lt;P&gt;I have created two arrays in sas:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;array x_array{5} x1-x5;&lt;BR /&gt;do i=1 to 5;&lt;BR /&gt;x_array[i]=i;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data two;&lt;BR /&gt;array y_array{5} y1-y5;&lt;BR /&gt;do i=1 to 5;&lt;BR /&gt;y_array[i]=i+1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;namely x_array=(1,2,3,4,5), y_array=(2,3,4,5,6).&lt;/P&gt;&lt;P&gt;Then how to create a 2 by 5 table as:&lt;/P&gt;&lt;P&gt;1,2,3,4,5&lt;/P&gt;&lt;P&gt;2,3,4,5,6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The following code creates a 2 by 10 table, which is not what i want. How to fix it? Thanks a lot.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data three;&lt;/P&gt;&lt;P&gt;set one two;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468742#M285475</guid>
      <dc:creator>liyongkai800</dc:creator>
      <dc:date>2018-06-08T15:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468746#M285476</link>
      <description>&lt;P&gt;You have defined 10 variables, x1-x5, and y1-y5.&amp;nbsp; Therefore when you set the two together, you get 10 variables in the output dataset.&amp;nbsp; If you only want 5 variables, then either the x1-5 should be y1-5 or the y should be x:&lt;/P&gt;
&lt;PRE&gt;data one;
  array x_array{5} x1-x5;
  do i=1 to 5;
    x_array[i]=i;
  end;
run;

data two;
  array y_array{5} x1-x5;
  do i=1 to 5;
    y_array[i]=i+1;
  end;
run;

data want;
  set one two;
run;&lt;/PRE&gt;
&lt;P&gt;You will then get five, x1-5, in the output.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468746#M285476</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-08T15:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468749#M285477</link>
      <description>&lt;P&gt;are you after this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data combined;
array x_array{5} x1-x5;
do i=1 to 5;
x_array[i]=i;
end;
output;
do i=1 to 5;
x_array[i]=i+1;
end;
output;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468749#M285477</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-08T15:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468750#M285478</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203676"&gt;@liyongkai800&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Fri, 08 Jun 2018 15:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468750#M285478</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2018-06-08T15:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468753#M285479</link>
      <description>&lt;P&gt;Arrays are not part of a data set, they are a way of temporarily grouping variables for processing in a data step. The variables may remain but the "array" does not persist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also all elements of an array appear on a single observation or row of data, there would be no 2 by 5 appearance.&lt;/P&gt;
&lt;P&gt;If you want to define and use an array that is logically 2 by 5 the approach would look something like:&lt;/P&gt;
&lt;PRE&gt;array xy{2,5}  x1-x5 y1-y5;
do i=1 to 2;
  do j= 1 to 5;
     xy[i,j]= &amp;lt;whatever&amp;gt;;
  end;
end;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468753#M285479</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-08T15:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468759#M285480</link>
      <description>Arrays and matrixes in SAS are not the same as other languages. If you want to work with arrays/matrix type logic, you can use PROC IML instead. It's best to understand how SAS works and use the base functionality to get the most efficiency.</description>
      <pubDate>Fri, 08 Jun 2018 15:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468759#M285480</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-08T15:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468767#M285481</link>
      <description>&lt;P&gt;I was thinking to rename all the variables as your suggestion, say change all the x's to y's. But I got hundreds of arrays, and all of them have different names for the variables.&amp;nbsp; Is there easier way that I don't have to change the name one by one? Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 16:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468767#M285481</guid>
      <dc:creator>liyongkai800</dc:creator>
      <dc:date>2018-06-08T16:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468771#M285482</link>
      <description>&lt;P&gt;Explain your use case? There are many other ways, but this is a contrived example that doesn't make a lot of sense.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL Insert INTO with a macro to handle the multiple tables&amp;nbsp;is one option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 16:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468771#M285482</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-08T16:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468774#M285483</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203676"&gt;@liyongkai800&lt;/a&gt;&amp;nbsp;You wrote&amp;nbsp;&lt;EM&gt;"Is there easier way that I don't have to change the name one by one? Thanks."&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you had a chance to look at my previous response. I believe that does exactly what you are looking for. Please correct me if i am wrong&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 16:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468774#M285483</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-08T16:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468779#M285484</link>
      <description>&lt;P&gt;What do arrays have to do with your question? If we remove them we can see easier what you are doing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input x1-x5 ;
cards;
1 2 3 4 5
;

data two;
  input y1-y5 ;
cards;
1 2 3 4 5
;

data three ;
  set one two;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 296px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21112i8586E1E56A80765F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If you want rename the variables in TWO to match the variables in ONE then use a rename statement or rename= dataset optoin.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data four ;
  set one two(rename=(y1-y5=x1-x5));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 175px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21113i2EC5563BB1B396A9/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 16:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/468779#M285484</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-08T16:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/469020#M285485</link>
      <description>&lt;P&gt;You do not have "hundreds of arrays".&amp;nbsp; Please read the manuals on what arrays are.&amp;nbsp; They are temporary arrays used for reference and only present in the datastep execution, they are not like arrays from other languages.&amp;nbsp; What you have is lots a variables.&amp;nbsp; So, in each of the datasets you set into your final dataset, you need to rename these to be consistent.&amp;nbsp; There are numerous ways to do this, simplest of which:&lt;/P&gt;
&lt;P&gt;Assumes:&lt;BR /&gt;DS1 = x1 to x5&lt;/P&gt;
&lt;P&gt;DS2 = y1 to y5&lt;/P&gt;
&lt;P&gt;DS3 = z1 to z5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set ds1
        ds2 (rename=(y1-y5=x1-x5))
        ds3 (rename=(z1-z5=x1-x5));
run;&lt;/PRE&gt;
&lt;P&gt;I suppose the underlying question here is why you have ended up with lots of datasets with the same data (as implied by your want), but with different variable names.&amp;nbsp; It sounds like your whole process has gone wrong earlier than this step and you would save yourself a lot of time and effort to fix it earlier on before the variables get created with different names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jun 2018 14:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-two-arrays/m-p/469020#M285485</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-10T14:28:14Z</dc:date>
    </item>
  </channel>
</rss>

