<?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: array? in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341540#M2116</link>
    <description>&lt;P&gt;Assuming you do create a SAS data set, and assuming that the variable names remain h1, h2, mx1, and mx2 ... the problem is difficult because the same observation could have h1=101 and h2=102. &amp;nbsp;So that observation has to be included in more than one set of means &amp;nbsp;This would be a way to process the data set 75 times to achieve the result you described:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro group_means;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%local i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%do i=101 %to 175;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; proc means data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;title "Statistics for &amp;amp;i";&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where h1=&amp;amp;i or h2=&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var mx1 mx2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%end;&lt;/P&gt;
&lt;P&gt;%mend group_means;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%group_means&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 12:05:01 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-03-16T12:05:01Z</dc:date>
    <item>
      <title>array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341489#M2109</link>
      <description>&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;h1 and h2 are index/&lt;/P&gt;&lt;P&gt;i want to group all h1=101 or h2=101 and calculate mx1 mx2 mean&lt;/P&gt;&lt;P&gt;so on to h1=175 or h2=175.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;this is example &amp;nbsp;of my data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;h1&lt;/TD&gt;&lt;TD&gt;mx1&lt;/TD&gt;&lt;TD&gt;h2&lt;/TD&gt;&lt;TD&gt;mx2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;25.2&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;220&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;220&lt;/TD&gt;&lt;TD&gt;24.7&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;255&lt;/TD&gt;&lt;TD&gt;15.1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;301&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;25.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;122&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;16&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 09:14:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341489#M2109</guid>
      <dc:creator>avikam</dc:creator>
      <dc:date>2017-03-16T09:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341492#M2110</link>
      <description>&lt;P&gt;Please post your example data in a data step, as described here: &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;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And post an example of your expected output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 09:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341492#M2110</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-16T09:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341505#M2111</link>
      <description>&lt;P&gt;POst test data in the form of a datastep, we are not here to either guess your data structure, nor act as data entry for you. &amp;nbsp;As such this is just theory:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  h_mean=mean(of h:);
  mx_mean=mean(of mx:);
run;&lt;/PRE&gt;
&lt;P&gt;Note the h: and mx: mean, all variable starting with h and mx respectively.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 09:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341505#M2111</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-16T09:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341507#M2112</link>
      <description>&lt;P&gt;i want collect the "101" from h1 column and &lt;SPAN&gt;column&amp;nbsp;&lt;/SPAN&gt;h2&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 09:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341507#M2112</guid>
      <dc:creator>avikam</dc:creator>
      <dc:date>2017-03-16T09:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341523#M2113</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134017"&gt;@avikam&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;i want collect the "101" from h1 column and &lt;SPAN&gt;column&amp;nbsp;&lt;/SPAN&gt;h2&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; means by "in the form of a data step".&amp;nbsp; This can be copied and pasted into SAS program.&amp;nbsp; Most folks don't want to download and EXCEL and fiddle with all that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data h;
   input h1 mx1 h2 mx2;
   cards;
101 25.2 175 25
175 24 220 22 
220 24.7 101 20
101 22 255 15.1
301 25 175 25.2
122 15 101 16
;;;;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 10:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341523#M2113</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-03-16T10:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341529#M2114</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134017"&gt;@avikam&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;i want collect the "101" from h1 column and &lt;SPAN&gt;column&amp;nbsp;&lt;/SPAN&gt;h2&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's not a SAS dataset. READ MY POST AGAIN.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 11:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341529#M2114</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-16T11:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341540#M2116</link>
      <description>&lt;P&gt;Assuming you do create a SAS data set, and assuming that the variable names remain h1, h2, mx1, and mx2 ... the problem is difficult because the same observation could have h1=101 and h2=102. &amp;nbsp;So that observation has to be included in more than one set of means &amp;nbsp;This would be a way to process the data set 75 times to achieve the result you described:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro group_means;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%local i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%do i=101 %to 175;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; proc means data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;title "Statistics for &amp;amp;i";&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where h1=&amp;amp;i or h2=&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var mx1 mx2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%end;&lt;/P&gt;
&lt;P&gt;%mend group_means;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%group_means&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 12:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341540#M2116</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-16T12:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341580#M2123</link>
      <description>&lt;P&gt;Is that what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tmp1;
 set have;
      h=h1; mx=mx1; output;
      h=h2; mx=mx2; output;
      keep h mx;
run;
proc means data=tmp1;
class h;
var mx;
output out=want mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341580#M2123</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-16T14:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341585#M2124</link>
      <description>&lt;P&gt;A couple of issues to consider ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;How do you limit the results to the range of 101 to 175?&lt;/LI&gt;
&lt;LI&gt;How do you get the right result when h1=h2?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;It's all fixable, but those details could matter.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341585#M2124</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-16T14:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/341590#M2125</link>
      <description>&lt;P&gt;I assumed you want the mean of mx1 and mx2 as one variable mx.&lt;/P&gt;
&lt;P&gt;The class=h eiminates to sort the data. When sorted you can use BY instead CLASS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I you want to select H1=h2 (=h) in the range 101-175 you can filter data by where statement as in:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=tmp1(where=(h between 101 and 175));
class h;
var mx;
output out=want mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/341590#M2125</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-16T14:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/342333#M2152</link>
      <description>&lt;P&gt;In my data h1 ne h2.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 07:06:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/342333#M2152</guid>
      <dc:creator>avikam</dc:creator>
      <dc:date>2017-03-19T07:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/342341#M2153</link>
      <description>&lt;P&gt;This is the data you posted:&lt;/P&gt;
&lt;PRE&gt;h1	mx1	h2	mx2
101	25.2	175	25
175	24	220	22
220	24.7	101	20
101	22	255	15.1
301	25	175	25.2
122	15	101	16&lt;/PRE&gt;
&lt;P&gt;And this was your request:&lt;/P&gt;
&lt;PRE&gt;i want to group all h1=101 or h2=101 and calculate mx1 mx2 mean&lt;/PRE&gt;
&lt;P&gt;Please explain, using above information, how would you calculate the mean &lt;STRONG&gt;manually&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 10:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/342341#M2153</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-19T10:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/342348#M2155</link>
      <description>For h1=101 or h2=101&lt;BR /&gt;&lt;BR /&gt;(25.2+20+22+16)/4&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And so son for h1=175 or h2=175&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 19 Mar 2017 13:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/342348#M2155</guid>
      <dc:creator>avikam</dc:creator>
      <dc:date>2017-03-19T13:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/342349#M2156</link>
      <description>&lt;P&gt;Have tried run the code i have sent to you ?&lt;/P&gt;
&lt;PRE&gt;Data tmp1;
 set have;
      h=h1; mx=mx1; output;
      h=h2; mx=mx2; output;
      keep h mx;
run;

/* use WHERE to select wanted range of h to calculate mean ) */
proc means data=tmp1(where=(h between 101 and 175));
class h;
var mx;
output out=want mean=;
run;&lt;/PRE&gt;
&lt;P&gt;Run the code and check results.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 13:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/342349#M2156</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-19T13:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/342365#M2157</link>
      <description>&lt;P&gt;I think Schmuel has the right idea here. &amp;nbsp;He follows what you want, where I was trying to compute separate means for mx1 and mx2.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 16:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/342365#M2157</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-19T16:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/342518#M2158</link>
      <description>&lt;P&gt;not yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wiil bs"d.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote Macro to solve the problem.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 10:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/342518#M2158</guid>
      <dc:creator>avikam</dc:creator>
      <dc:date>2017-03-20T10:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/342521#M2159</link>
      <description>&lt;P&gt;this is my macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro ib;&lt;BR /&gt;%DO II=1 %to 175;&lt;BR /&gt;data aa&amp;amp;II;&lt;BR /&gt;set a1;&lt;/P&gt;&lt;P&gt;if h1=&amp;amp;ii or h2=&amp;amp;ii;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc means;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend ib;&lt;BR /&gt;&lt;BR /&gt;%ib&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 10:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/342521#M2159</guid>
      <dc:creator>avikam</dc:creator>
      <dc:date>2017-03-20T10:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: array?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/array/m-p/342573#M2160</link>
      <description>&lt;P&gt;So it sounds like you first should convert your data from wide to tall format and then you can calculate the mean.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall ;
  set have ;
  h=h1; mx=mx1; output;
  h=h2; mx=mx2; output;
  keep h mx ;
run;

proc means data=tall ;
  where h in (101 175);
  class h ;
  var mx;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Mar 2017 13:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/array/m-p/342573#M2160</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-20T13:17:47Z</dc:date>
    </item>
  </channel>
</rss>

