<?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: comparing variables whose observations are semi-exclusive in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/comparing-variables-whose-observations-are-semi-exclusive/m-p/831619#M328644</link>
    <description>&lt;P&gt;ANOVA compares observarions, not variables. So you need to transpose your data first. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Student $   Grad  y2016  y2017   y2018   y2019   y2020;
datalines;
student1  2018   58      83       108 . .
student2  2018   60      86       103 . .
student3  2018   63       80       110  . .
studenta  2018   59       82       106  . .
student4  2019     .        57         84      113 .
student5  2019     .        61         79      117 .
student6  2019     .        64         82      109 .
studentb  2019     .        60         81      115 .
student7  2020     .          .           55        80     117
student8  2020     .          .           61        82     121
student9  2020     .          .           62        87     116
studentc  2020     .          .           57        85     118
;

proc transpose data=have out=temp1 prefix=yr; by student grad notsorted; run;

data temp2;
set temp1;
if yr1;
year = input(substr(_name_,2), 4.);
aYear = year - grad + 3; /* student academic year */
keep student grad year aYear yr1;
rename yr1 = labHours;
run;

proc glm data=temp2;
class aYear year;
model labHours = aYear year / solution;
lsmeans aYear;
lsmeans year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: this is testing for main effects only. Interactions between year and academic year are not estimable.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Sep 2022 20:40:15 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2022-09-02T20:40:15Z</dc:date>
    <item>
      <title>comparing variables whose observations are semi-exclusive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/comparing-variables-whose-observations-are-semi-exclusive/m-p/831600#M328633</link>
      <description>&lt;P&gt;How would I run an anova table for lab usage by year and academic year and get true variances if many cells are empty? My dataset is sorted by graduation year in a 3-year academic program, with lab hours recorded in the following fashion (the actual dataset is much larger: 70 observations and 29 variables)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Student&amp;nbsp; &amp;nbsp; Grad&amp;nbsp; 2016&amp;nbsp; 2017&amp;nbsp; &amp;nbsp;2018&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;2020&lt;/P&gt;&lt;P&gt;student1&amp;nbsp; 2018&amp;nbsp; &amp;nbsp;58&amp;nbsp; &amp;nbsp; &amp;nbsp; 83&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;108&lt;/P&gt;&lt;P&gt;student2&amp;nbsp; 2018&amp;nbsp; &amp;nbsp;60&amp;nbsp; &amp;nbsp; &amp;nbsp; 86&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;103&lt;/P&gt;&lt;P&gt;student3&amp;nbsp; 2018&amp;nbsp; &amp;nbsp;63&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;80&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;110&lt;/P&gt;&lt;P&gt;student4&amp;nbsp; 2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;57&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;84&amp;nbsp; &amp;nbsp; &amp;nbsp; 113&lt;/P&gt;&lt;P&gt;student5&amp;nbsp; 2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;61&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;79&amp;nbsp; &amp;nbsp; &amp;nbsp; 117&lt;/P&gt;&lt;P&gt;student6&amp;nbsp; 2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;64&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;82&amp;nbsp; &amp;nbsp; &amp;nbsp; 109&lt;/P&gt;&lt;P&gt;student7&amp;nbsp; 2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 55&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 80&amp;nbsp; &amp;nbsp; &amp;nbsp;117&lt;/P&gt;&lt;P&gt;student8&amp;nbsp; 2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 61&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 82&amp;nbsp; &amp;nbsp; &amp;nbsp;121&lt;/P&gt;&lt;P&gt;student9&amp;nbsp; 2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 62&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 87&amp;nbsp; &amp;nbsp; &amp;nbsp;116&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any and all help is appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 18:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/comparing-variables-whose-observations-are-semi-exclusive/m-p/831600#M328633</guid>
      <dc:creator>newtriks</dc:creator>
      <dc:date>2022-09-02T18:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: comparing variables whose observations are semi-exclusive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/comparing-variables-whose-observations-are-semi-exclusive/m-p/831619#M328644</link>
      <description>&lt;P&gt;ANOVA compares observarions, not variables. So you need to transpose your data first. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Student $   Grad  y2016  y2017   y2018   y2019   y2020;
datalines;
student1  2018   58      83       108 . .
student2  2018   60      86       103 . .
student3  2018   63       80       110  . .
studenta  2018   59       82       106  . .
student4  2019     .        57         84      113 .
student5  2019     .        61         79      117 .
student6  2019     .        64         82      109 .
studentb  2019     .        60         81      115 .
student7  2020     .          .           55        80     117
student8  2020     .          .           61        82     121
student9  2020     .          .           62        87     116
studentc  2020     .          .           57        85     118
;

proc transpose data=have out=temp1 prefix=yr; by student grad notsorted; run;

data temp2;
set temp1;
if yr1;
year = input(substr(_name_,2), 4.);
aYear = year - grad + 3; /* student academic year */
keep student grad year aYear yr1;
rename yr1 = labHours;
run;

proc glm data=temp2;
class aYear year;
model labHours = aYear year / solution;
lsmeans aYear;
lsmeans year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: this is testing for main effects only. Interactions between year and academic year are not estimable.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 20:40:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/comparing-variables-whose-observations-are-semi-exclusive/m-p/831619#M328644</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-09-02T20:40:15Z</dc:date>
    </item>
  </channel>
</rss>

