<?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: Passing a vector or matrix of regressor values into statement: lsmeans/at (x y)=(vector x,y valu in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Passing-a-vector-or-matrix-of-regressor-values-into-statement/m-p/257250#M13593</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/47281"&gt;@treetop﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using CALL EXECUTE you could create one LSMEANS statement per observation in your external dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test dataset with regressor values */

data regr;
input r s t;
cards;
1.2 0.3 -0.5
1.5 0.7  0.1
;

/* Call PROC MIXED with one LSMEANS statement per obs. in dataset REGR */

data _null_;
set regr end=last;
if _n_=1 then
call execute('proc mixed data=test;'
          || 'class a;'
          || 'model y = a r s t r*s;');
call execute('lsmeans a / cl at (r--t)=('||catx(' ', of r--t)||');');
if last then
call execute('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This would create and execute the following PROC MIXED code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc mixed data=test;class a;model y = a r s t r*s;
lsmeans a / cl at (r--t)=(1.2 0.3 -0.5);
lsmeans a / cl at (r--t)=(1.5 0.7 0.1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just adapt the PROC MIXED code and the regressor variable names and values to your requirements.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Mar 2016 10:54:02 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-03-17T10:54:02Z</dc:date>
    <item>
      <title>Passing a vector or matrix of regressor values into statement: lsmeans/at (x y)=(vector x,y values)</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Passing-a-vector-or-matrix-of-regressor-values-into-statement/m-p/257246#M13591</link>
      <description>&lt;P&gt;After fitting a model (e.g. proc mixed) I now wish to make predictions of the mean and 95% CI&amp;nbsp;using LSMEANS statement and option AT. The AT option allows many regressors but only 1 value each.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have made an external dataset of fixed values for regressors.&lt;/P&gt;&lt;P&gt;I would like pass each row of regressor values to the lsmeans/at statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way of getting the lsmeans statement (within proc mixed) to accept the matrix of regressor values?&lt;/P&gt;&lt;P&gt;If not, and I have to (somehow) use a loop, please could you tell or point me to a resource that provides me with code for this complicated task of passing data row-by-row from an external dataset to the scalar lsmeans/at statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 09:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Passing-a-vector-or-matrix-of-regressor-values-into-statement/m-p/257246#M13591</guid>
      <dc:creator>treetop</dc:creator>
      <dc:date>2016-03-17T09:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a vector or matrix of regressor values into statement: lsmeans/at (x y)=(vector x,y valu</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Passing-a-vector-or-matrix-of-regressor-values-into-statement/m-p/257250#M13593</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/47281"&gt;@treetop﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using CALL EXECUTE you could create one LSMEANS statement per observation in your external dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test dataset with regressor values */

data regr;
input r s t;
cards;
1.2 0.3 -0.5
1.5 0.7  0.1
;

/* Call PROC MIXED with one LSMEANS statement per obs. in dataset REGR */

data _null_;
set regr end=last;
if _n_=1 then
call execute('proc mixed data=test;'
          || 'class a;'
          || 'model y = a r s t r*s;');
call execute('lsmeans a / cl at (r--t)=('||catx(' ', of r--t)||');');
if last then
call execute('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This would create and execute the following PROC MIXED code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc mixed data=test;class a;model y = a r s t r*s;
lsmeans a / cl at (r--t)=(1.2 0.3 -0.5);
lsmeans a / cl at (r--t)=(1.5 0.7 0.1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just adapt the PROC MIXED code and the regressor variable names and values to your requirements.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 10:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Passing-a-vector-or-matrix-of-regressor-values-into-statement/m-p/257250#M13593</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-17T10:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a vector or matrix of regressor values into statement: lsmeans/at (x y)=(vector x,y valu</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Passing-a-vector-or-matrix-of-regressor-values-into-statement/m-p/257254#M13596</link>
      <description>Great thanks to FreelanceReinhard for your help, this worked fantastic!</description>
      <pubDate>Thu, 17 Mar 2016 11:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Passing-a-vector-or-matrix-of-regressor-values-into-statement/m-p/257254#M13596</guid>
      <dc:creator>treetop</dc:creator>
      <dc:date>2016-03-17T11:20:38Z</dc:date>
    </item>
  </channel>
</rss>

