<?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 make arrays from multiple datasets. using array (Create two arrays that can be used to ac in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-arrays-from-multiple-datasets-using-array-Create-two/m-p/375718#M90112</link>
    <description>&lt;P&gt;In your last step you access high_sorted, its likely you want to access the both dataset - i.e. the dataset you merge before hand to get all those variables into one dataset. &amp;nbsp;Maybe something like this (and updated the formatting so its more readable - also note that a and b are bolean 1 or 0, so you don't need the a=1, just a);&lt;/P&gt;
&lt;PRE&gt;proc sort data=data.ok_mid out=mid_sorted (rename=(grade7-grade12=ms_grade7-ms_grade12)); 
  by mapcity school; 
run;

proc sort data=data.ok_high out=high_sorted (rename=(grade7-grade12=hs_grade7-hs_grade12)); 
  by mapcity school; 
run;

data both midonly (keep=school mapcity mailcity county) hsonly (keep=school mapcity mailcity county);
  merge  mid_sorted (in=a) 
  	 high_sorted (in=b);
  by mapcity school;
  if a and b then output both; 
  else if not(a) and b then output hsonly;
  else output midonly;
run;

data;
  set both;
  array hs_array {6} hs_grade7-hs_grade12;
  array ms_array {6} ms_grade7-ms_grade12;
  array new_array {6} grade7-grade12;
  do i=1 to 6;
    new_array{i}=hs_array{i} + ms_array{i};
  end;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2017 14:56:09 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-07-13T14:56:09Z</dc:date>
    <item>
      <title>How to make arrays from multiple datasets. using array (Create two arrays that can be used to access</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-arrays-from-multiple-datasets-using-array-Create-two/m-p/375707#M90106</link>
      <description>&lt;P&gt;task &amp;gt; Create two arrays that can be used to access the number of students in grades 7&lt;/P&gt;&lt;P&gt;through 12 from each of your two input data sets. Create a third array that will&lt;/P&gt;&lt;P&gt;create and access new variables named Grade7 through Grade12.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have two data sets ok_mid and ok_high, now i want to make two arrays to access Grade7 - Grade12 from both data sets to add them. So far i have only seen one array - one data sets in a scope examples. how can i achieve&amp;nbsp;above task&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;PRE&gt;proc sort data=data.ok_mid out=mid_sorted(rename=(Grade7-Grade12=MS_Grade7-MS_Grade12)); by MapCity School; run;
proc sort data=data.ok_high out=high_sorted(rename=(Grade7-Grade12=HS_Grade7-HS_Grade12)); by MapCity School; run;

data Both Midonly (keep=School MapCity MailCity County) HSonly (keep=School MapCity MailCity County);
merge mid_sorted (in=A) 
	  high_sorted (in=B);
by MapCity School;
if A=1 and B=1 then output Both; 
/*(b) create a temporary data set of high schools with no matching record in ok_mid*/
else if A=0 and B=1 then output HSonly;
/*(c) create a temporary data set of middle schools with no matching record in ok_high*/
else if A=1 and B=0 then output Midonly;
run;

data;
	set high_sorted;
	array hs_array {6} HS_Grade7-HS_grade12;
	set mid_sorted;
	array ms_array {6} MS_Grade7-MS_Grade12;
	array new_array {6} Grade7-Grade12;
	do i =1 to 6;
		new_array[i] = hs_array[i] + ms_array[i];
	end;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 14:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-arrays-from-multiple-datasets-using-array-Create-two/m-p/375707#M90106</guid>
      <dc:creator>Sir1</dc:creator>
      <dc:date>2017-07-13T14:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to make arrays from multiple datasets. using array (Create two arrays that can be used to ac</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-arrays-from-multiple-datasets-using-array-Create-two/m-p/375718#M90112</link>
      <description>&lt;P&gt;In your last step you access high_sorted, its likely you want to access the both dataset - i.e. the dataset you merge before hand to get all those variables into one dataset. &amp;nbsp;Maybe something like this (and updated the formatting so its more readable - also note that a and b are bolean 1 or 0, so you don't need the a=1, just a);&lt;/P&gt;
&lt;PRE&gt;proc sort data=data.ok_mid out=mid_sorted (rename=(grade7-grade12=ms_grade7-ms_grade12)); 
  by mapcity school; 
run;

proc sort data=data.ok_high out=high_sorted (rename=(grade7-grade12=hs_grade7-hs_grade12)); 
  by mapcity school; 
run;

data both midonly (keep=school mapcity mailcity county) hsonly (keep=school mapcity mailcity county);
  merge  mid_sorted (in=a) 
  	 high_sorted (in=b);
  by mapcity school;
  if a and b then output both; 
  else if not(a) and b then output hsonly;
  else output midonly;
run;

data;
  set both;
  array hs_array {6} hs_grade7-hs_grade12;
  array ms_array {6} ms_grade7-ms_grade12;
  array new_array {6} grade7-grade12;
  do i=1 to 6;
    new_array{i}=hs_array{i} + ms_array{i};
  end;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 14:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-arrays-from-multiple-datasets-using-array-Create-two/m-p/375718#M90112</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-13T14:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to make arrays from multiple datasets. using array (Create two arrays that can be used to ac</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-arrays-from-multiple-datasets-using-array-Create-two/m-p/375724#M90113</link>
      <description>&lt;P&gt;First, get your data in the form you need it. Are the multiple SET statements in the last step creating a dataset in the right format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If no, figure that out first and then you can declare as many arrays as you want. I suspect you should be using the BOTH dataset. &amp;nbsp;Or a version with all of the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Arrays in SAS are only a short cut reference to the variables. They don't store data per se, just make it easier to reference a variable with an index.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 15:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-arrays-from-multiple-datasets-using-array-Create-two/m-p/375724#M90113</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-13T15:01:38Z</dc:date>
    </item>
  </channel>
</rss>

