<?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: Create a new dataset with average plot values calculated from individual data points in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410558#M67288</link>
    <description>&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table average as&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select *, mean(score) as average_score&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from sample&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;group by block, line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 04 Nov 2017 16:11:59 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-11-04T16:11:59Z</dc:date>
    <item>
      <title>Create a new dataset with average plot values calculated from individual data points</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410556#M67286</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have experiments with multiple plants that make up one plot, and plots are treated as experimental units within blocks. I typically use excel to calculate the mean of the plants within a plot, and then transfer those values to a new sheet to load into SAS and analyze. However, I want to use SAS to perform this step instead (SAS 9.4). For an example, this is a sample dataset with three plots (A, B, and C) each having 4 plants with a measurement (score). Then there are three blocks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sample;&lt;BR /&gt;input block line$ plant score;&lt;BR /&gt;cards;&lt;BR /&gt;1 A 1 3&lt;BR /&gt;1 A 2 2&lt;BR /&gt;1 A 3 4&lt;BR /&gt;1 A 4 3&lt;BR /&gt;1 B 1 4&lt;BR /&gt;1 B 2 3&lt;BR /&gt;1 B 3 5&lt;BR /&gt;1 B 4 4&lt;BR /&gt;1 C 1 2&lt;BR /&gt;1 C 2 2&lt;BR /&gt;1 C 3 3&lt;BR /&gt;1 C 4 2&lt;BR /&gt;2 A 1 4&lt;BR /&gt;2 A 2 5&lt;BR /&gt;2 A 3 5&lt;BR /&gt;2 A 4 5&lt;BR /&gt;2 B 1 3&lt;BR /&gt;2 B 2 2&lt;BR /&gt;2 B 3 3&lt;BR /&gt;2 B 4 3&lt;BR /&gt;2 C 1 3&lt;BR /&gt;2 C 2 2&lt;BR /&gt;2 C 3 2&lt;BR /&gt;2 C 4 2&lt;BR /&gt;3 A 1 5&lt;BR /&gt;3 A 2 6&lt;BR /&gt;3 A 3 6&lt;BR /&gt;3 A 4 5&lt;BR /&gt;3 B 1 4&lt;BR /&gt;3 B 2 3&lt;BR /&gt;3 B 3 4&lt;BR /&gt;3 B 4 2&lt;BR /&gt;3 C 1 2&lt;BR /&gt;3 C 2 2&lt;BR /&gt;3 C 3 3&lt;BR /&gt;3 C 4 2&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I want a dataset now with average values for each A, B, or C within each block that I can then use for analysis. I've found somewhat similar examples using proc sql&amp;nbsp;or proc means, but I get errors when I try to implement. For example:&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table average as&lt;BR /&gt;select *, mean(score) as average_score&lt;BR /&gt;from sample&lt;BR /&gt;by block&lt;BR /&gt;where line between 'A' and 'A'&lt;BR /&gt;and plant between 1 and 4;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;and this didn't work, the error message said&amp;nbsp;ERROR 78-322: Expecting a ','. so I know I'm missing something.... this seems like such a simple thing, I know there must be an answer. Any help will be greatly appreciated!! Thank you so much!&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 16:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410556#M67286</guid>
      <dc:creator>jchitw12</dc:creator>
      <dc:date>2017-11-04T16:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new dataset with average plot values calculated from individual data points</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410557#M67287</link>
      <description>&lt;P&gt;Here are two fully worked methods, see if you can incorporate one with your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error you state versus the code you've shown don't make sense. I would suggest posting the exact code and log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset.sas" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 16:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410557#M67287</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-04T16:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new dataset with average plot values calculated from individual data points</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410558#M67288</link>
      <description>&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table average as&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select *, mean(score) as average_score&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from sample&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;group by block, line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 16:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410558#M67288</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-04T16:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new dataset with average plot values calculated from individual data points</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410560#M67289</link>
      <description>&lt;P&gt;That did the trick. Thank you so much!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2017 16:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-new-dataset-with-average-plot-values-calculated-from/m-p/410560#M67289</guid>
      <dc:creator>jchitw12</dc:creator>
      <dc:date>2017-11-04T16:15:44Z</dc:date>
    </item>
  </channel>
</rss>

