<?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: What is the OBSMARGINS dataset format for PROC GENMOD? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790712#M38770</link>
    <description>&lt;P&gt;It's not at all clear what your ultimate goal is with this, but it appears that you simply have an observed proportion for each of three groups. If the goal is to compare those group proportions, this can be done by fitting an appropriate model and using the NLMeans macro to make pairwise comparisons. Since the data are just counts from an aggregated binary response, the appropriate model is a logistic model. The following code fits the model and then does the comparisons with the NLMeans macro following the discussion in &lt;A href="https://support.sas.com/kb/37/228.html" target="_self"&gt;this note&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cohorts;
input cohort num den;
datalines;
1 10 100
2 9 100
3 1 2
;
proc logistic data=cohorts;
class cohort/param=glm;
model num/den = cohort;
lsmeans cohort / ilink e diff cl;
ods output coef=c;
store log;
run;
%nlmeans(instore=log, coef=c, link=logit)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 18 Jan 2022 17:06:48 GMT</pubDate>
    <dc:creator>StatDave</dc:creator>
    <dc:date>2022-01-18T17:06:48Z</dc:date>
    <item>
      <title>What is the OBSMARGINS dataset format for PROC GENMOD?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790651#M38763</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to specify coefficients for LSMEANS class levels in PROC GENMOD, but am struggling to get this working. Consider the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data cohorts;
   fixed = 1;
   cohort = 1; numer = 10; ldenom = log(100); output;
   cohort = 2; numer =  9; ldenom = log(100); output;
   cohort = 3; numer =  1; ldenom =   log(2); output;
run;

proc genmod data=cohorts;
   class cohort fixed;
   model numer = fixed cohort / dist=poisson offset=ldenom;
   lsmeans fixed / e diff cl;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would&amp;nbsp;&lt;EM&gt;like&lt;/EM&gt; the LSMEANS coefficients (&lt;STRONG&gt;e&lt;/STRONG&gt; option) for cohort to be 0.495, 0.495 and 0.01 respectively based on the denom values, but they default to 0.333 each. I see that &lt;STRONG&gt;OBSMARGINS=&amp;lt;OM-data-set&amp;gt;&lt;/STRONG&gt;&amp;nbsp;should let me specify this, and I also see that this dataset should contain 'all model variables except the dependent one' (fixed and cohort in my case), but I don't see how I specify the value of the coefficient itself. Not specifying a dataset doesn't change anything if the input is in this 'one record with all observations per cohort' format, which is unfortunately all I have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This feels like it should be easy but I'm completely failing to find any example or specification for this OM dataset format, any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 10:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790651#M38763</guid>
      <dc:creator>pblls</dc:creator>
      <dc:date>2022-01-18T10:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: What is the OBSMARGINS dataset format for PROC GENMOD?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790656#M38764</link>
      <description>&lt;P&gt;After some further testing it seems like it's just the number of observations in the OM dataset that matters, i.e. the following addition should be correct:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data obsm;
   fixed = 1;
   cohort = 1; do i = 1 to 100; output; end;
   cohort = 2; do i = 1 to 100; output; end;
   cohort = 3; do i = 1 to   2; output; end;
   drop i;
run;

proc genmod data=cohorts;
   ...
   lsmeans fixed / ... om=obsm;
run;

&lt;/PRE&gt;&lt;P&gt;The problem is now that this gives a segfault in PROC GENMOD on our central SAS installation, so I guess we'll be reaching out to Tech Support.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 10:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790656#M38764</guid>
      <dc:creator>pblls</dc:creator>
      <dc:date>2022-01-18T10:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: What is the OBSMARGINS dataset format for PROC GENMOD?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790664#M38765</link>
      <description>&lt;P&gt;What version of SAS are you running? Submit&lt;/P&gt;
&lt;P&gt;%put &amp;amp;=SYSVLONG4;&lt;/P&gt;
&lt;P&gt;and send back the line that appears in the log that looks something like this:&lt;/P&gt;
&lt;P&gt;121 %put &amp;amp;=SYSVLONG4;&lt;BR /&gt;SYSVLONG4=9.04.01M6P11072018&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run your program on SAS 9.4m7, it does not crash and it gives an answer, so perhaps this issue has been resolved in a more recent version of SAS.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your program, the FIXED variable has only one level. That is a degenerate situation. Please try your program when the CLASS variables have more than one level. For example, you might try running the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cohorts;
   do fixed = 1 to 2;
      cohort = 1; numer = 10; ldenom = log(100); output;
      cohort = 2; numer =  9; ldenom = log(100); output;
      cohort = 3; numer =  1; ldenom =   log(2); output;
   end;
run;

proc genmod data=cohorts;
   class cohort fixed;
   model numer = fixed cohort / dist=poisson offset=ldenom;
   lsmeans fixed / e diff cl;
run;

data obsm;
   do fixed = 1 to 2;
      cohort = 1; do i = 1 to 100; output; end;
      cohort = 2; do i = 1 to 100; output; end;
      cohort = 3; do i = 1 to   2; output; end;
   end;
   drop i;
run;

proc genmod data=cohorts;
   class cohort fixed;
   model numer = fixed cohort / dist=poisson offset=ldenom;
   lsmeans fixed /  e diff cl om=obsm;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jan 2022 11:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790664#M38765</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-01-18T11:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: What is the OBSMARGINS dataset format for PROC GENMOD?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790687#M38767</link>
      <description>&lt;P&gt;We're also on 9.4M7:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SYSVLONG4=9.04.01M7P08052020&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My example and your extension both work on a second installation of SAS (and not on the server), but if I try to run it with some actual data (a few thousand observations in the obsm dataset) I also get a segfault on that local environment... both are running the same SAS version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will probably not be fixed with just some additional SAS code, so I'll try to get some technical support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To continue in the spirit of this thread, is there a way to specify the margins without creating that number of observations? Ideally I would like to do something like this and not need a huge number of records:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data obsm;
   do fixed = 1, 2;
      cohort = 1; _MARGIN_ = 100; output;
      cohort = 2; _MARGIN_ = 100; output;
      cohort = 3; _MARGIN_ =   2; output;&lt;BR /&gt;   end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jan 2022 14:13:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790687#M38767</guid>
      <dc:creator>pblls</dc:creator>
      <dc:date>2022-01-18T14:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: What is the OBSMARGINS dataset format for PROC GENMOD?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790712#M38770</link>
      <description>&lt;P&gt;It's not at all clear what your ultimate goal is with this, but it appears that you simply have an observed proportion for each of three groups. If the goal is to compare those group proportions, this can be done by fitting an appropriate model and using the NLMeans macro to make pairwise comparisons. Since the data are just counts from an aggregated binary response, the appropriate model is a logistic model. The following code fits the model and then does the comparisons with the NLMeans macro following the discussion in &lt;A href="https://support.sas.com/kb/37/228.html" target="_self"&gt;this note&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cohorts;
input cohort num den;
datalines;
1 10 100
2 9 100
3 1 2
;
proc logistic data=cohorts;
class cohort/param=glm;
model num/den = cohort;
lsmeans cohort / ilink e diff cl;
ods output coef=c;
store log;
run;
%nlmeans(instore=log, coef=c, link=logit)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jan 2022 17:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790712#M38770</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2022-01-18T17:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: What is the OBSMARGINS dataset format for PROC GENMOD?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790855#M38773</link>
      <description>&lt;P&gt;Ah, yes, I didn't really go into the 'why' because unfortunately we're mostly stuck with this method for historical reasons. The goal is to provide confidence intervals for an event rate, and without the covariate the model matches very closely with the method of Ulm (&lt;SPAN&gt;10.1093/oxfordjournals.aje.a115507) which was used on the pool of cohorts.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data are event counts with follow-up time in the denominator, and while I only have aggregates across cohorts individuals may have counts &amp;gt;1, so I'm not sure if logistic regression is appropriate here?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 11:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790855#M38773</guid>
      <dc:creator>pblls</dc:creator>
      <dc:date>2022-01-19T11:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: What is the OBSMARGINS dataset format for PROC GENMOD?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790896#M38775</link>
      <description>&lt;P&gt;If you counted the number of events that occur in each cohort (the numerator) out of a total number of observed individuals in each cohort (the denominator), then at the individual level the response is binomial and the logistic model is appropriate. If, for some reason, you want to assume that the cohorts have the same event probability, then you could simply remove COHORT from the model and estimate the common event probability:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc logistic data=cohorts;
model num/den = ;
estimate 'pr' intercept 1 / ilink;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jan 2022 14:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/What-is-the-OBSMARGINS-dataset-format-for-PROC-GENMOD/m-p/790896#M38775</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2022-01-19T14:37:47Z</dc:date>
    </item>
  </channel>
</rss>

