<?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 Case counts with logistic regression in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774001#M37846</link>
    <description>&lt;P&gt;I am running a logistic regression on 1714 variables (PheWAS). I followed this guide (&lt;A href="https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html&lt;/A&gt;) to run the regression the "by way."&lt;/P&gt;&lt;P&gt;In my final table, I would like to have the number of cases for each predictor (the predictor/exposure is a SNP (genetic variant) yes/no). In my final logistic table I have removed the reference row.&amp;nbsp; Each row is one logistic regression and unique on varname.&lt;/P&gt;&lt;P&gt;Table that I get&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Varname&lt;/TD&gt;&lt;TD&gt;p-value&lt;/TD&gt;&lt;TD&gt;odds ratio&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_001&lt;/TD&gt;&lt;TD&gt;.002&lt;/TD&gt;&lt;TD&gt;10.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_002&lt;/TD&gt;&lt;TD&gt;.6&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the table that I want&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Varname&lt;/TD&gt;&lt;TD&gt;p-value&lt;/TD&gt;&lt;TD&gt;odds ratio&lt;/TD&gt;&lt;TD&gt;cases_SNP_yes&lt;/TD&gt;&lt;TD&gt;cases_SNP_no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_001&lt;/TD&gt;&lt;TD&gt;0.002&lt;/TD&gt;&lt;TD&gt;10.2&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_002&lt;/TD&gt;&lt;TD&gt;0.6&lt;/TD&gt;&lt;TD&gt;1.0&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;The way I currently get cases is to run a proc means step on the input data set (one row per patient (obs=264,000), one column per variable, and a column that indicates exposure) and then merge it with the logistic output by varname. I then repeat the step to get the number of cases for the other predictor. However, this takes a long time and I would think there is a better way to do this. I am wondering if there is an option statement in the proc logistic statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample code is below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;* code for how I get my logistic table;
proc logistic data = have / alpha=0.00002927;
	by VarName; *this is the "by way" ;
	class SNP ;
	model value = SNP / rsq expb; 
	ods output ParameterEstimates=model ;
quit;

data model_formated;
	set model (rename=(expest=odds_ratio));
	where variable = 'SNP'; *keep the row that contain the p value
run;

proc means data=have sum;
by varname ;
where SNP=1;
var value;
output out=cases
sum=count;
run;

data logistic_with_counts;
	merge model_formated cases(keep=varname count);
	by varname;
run;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Oct 2021 18:24:59 GMT</pubDate>
    <dc:creator>lauldani</dc:creator>
    <dc:date>2021-10-13T18:24:59Z</dc:date>
    <item>
      <title>Case counts with logistic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774001#M37846</link>
      <description>&lt;P&gt;I am running a logistic regression on 1714 variables (PheWAS). I followed this guide (&lt;A href="https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html&lt;/A&gt;) to run the regression the "by way."&lt;/P&gt;&lt;P&gt;In my final table, I would like to have the number of cases for each predictor (the predictor/exposure is a SNP (genetic variant) yes/no). In my final logistic table I have removed the reference row.&amp;nbsp; Each row is one logistic regression and unique on varname.&lt;/P&gt;&lt;P&gt;Table that I get&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Varname&lt;/TD&gt;&lt;TD&gt;p-value&lt;/TD&gt;&lt;TD&gt;odds ratio&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_001&lt;/TD&gt;&lt;TD&gt;.002&lt;/TD&gt;&lt;TD&gt;10.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_002&lt;/TD&gt;&lt;TD&gt;.6&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the table that I want&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Varname&lt;/TD&gt;&lt;TD&gt;p-value&lt;/TD&gt;&lt;TD&gt;odds ratio&lt;/TD&gt;&lt;TD&gt;cases_SNP_yes&lt;/TD&gt;&lt;TD&gt;cases_SNP_no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_001&lt;/TD&gt;&lt;TD&gt;0.002&lt;/TD&gt;&lt;TD&gt;10.2&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;_002&lt;/TD&gt;&lt;TD&gt;0.6&lt;/TD&gt;&lt;TD&gt;1.0&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;The way I currently get cases is to run a proc means step on the input data set (one row per patient (obs=264,000), one column per variable, and a column that indicates exposure) and then merge it with the logistic output by varname. I then repeat the step to get the number of cases for the other predictor. However, this takes a long time and I would think there is a better way to do this. I am wondering if there is an option statement in the proc logistic statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample code is below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;* code for how I get my logistic table;
proc logistic data = have / alpha=0.00002927;
	by VarName; *this is the "by way" ;
	class SNP ;
	model value = SNP / rsq expb; 
	ods output ParameterEstimates=model ;
quit;

data model_formated;
	set model (rename=(expest=odds_ratio));
	where variable = 'SNP'; *keep the row that contain the p value
run;

proc means data=have sum;
by varname ;
where SNP=1;
var value;
output out=cases
sum=count;
run;

data logistic_with_counts;
	merge model_formated cases(keep=varname count);
	by varname;
run;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 18:24:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774001#M37846</guid>
      <dc:creator>lauldani</dc:creator>
      <dc:date>2021-10-13T18:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Case counts with logistic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774003#M37847</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;In my final table, I would like to have the number of cases for each class (exposure is one of two drugs - studyrx is the column name). In my final logistic table, I have removed the reference row.&amp;nbsp; Each row is one logistic regression and unique on varname.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Varname&lt;/TD&gt;
&lt;TD&gt;p-value&lt;/TD&gt;
&lt;TD&gt;odds ratio&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;_001&lt;/TD&gt;
&lt;TD&gt;.002&lt;/TD&gt;
&lt;TD&gt;10.2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;_002&lt;/TD&gt;
&lt;TD&gt;.6&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ask for clarification here. What do you mean by "number of cases"? What do you mean by "each class"? Can you show us the table you would like, even if the numbers are fake and explain wehre the real numbers come from?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as the overall problem that it takes too long is concerned, please tell me, what are you going to do with these 1714 logistic regression results once you have them. There may be smarter ways to do this, rather than ways to speed up the time it takes to do 1714 regressions.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 17:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774003#M37847</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-13T17:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Case counts with logistic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774010#M37849</link>
      <description>&lt;P&gt;I am trying to run a PhewAS (&lt;A href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4666492/" target="_blank"&gt;https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4666492/&lt;/A&gt;) in SAS; for reasons, I can't run it in R. Therefore, the multiple regression is the procedure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each variable has a response 1=yes and 0=no. The number of cases is the number of "yeses". I want to know the number of "yeses" broken down by each predictor. I don't &lt;U&gt;need&lt;/U&gt; to know this, but displaying this information is the standard.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 18:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774010#M37849</guid>
      <dc:creator>lauldani</dc:creator>
      <dc:date>2021-10-13T18:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Case counts with logistic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774014#M37850</link>
      <description>&lt;P&gt;Number of cases can be computed via PROC FREQ and then added into the PROC LOGISTIC output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With &amp;gt;1700 variables, the logistic regressions should take a while, and I am not aware of a method to speed this up, as you are using the fastest method I know of.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 18:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774014#M37850</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-13T18:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Case counts with logistic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774020#M37852</link>
      <description>Consider adding the SIMPLE option to your PROC LOGISITIC and then capture it in an ODS statement as well.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2021 19:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774020#M37852</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-13T19:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Case counts with logistic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774023#M37853</link>
      <description>You should always specify the EVENT= response option to be sure you are modeling the probability of the event  level and not the nonevent level. For example:  model value(event="Yes") = ... .  The number of cases (events) and nonevents is in the Response Profile table that is automatically displayed. You can save it by also saving the ResponseProfile table in your ODS OUTPUT statement.</description>
      <pubDate>Wed, 13 Oct 2021 19:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774023#M37853</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2021-10-13T19:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Case counts with logistic regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774187#M37869</link>
      <description>&lt;P&gt;That is exactly what I was looking for. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 11:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Case-counts-with-logistic-regression/m-p/774187#M37869</guid>
      <dc:creator>lauldani</dc:creator>
      <dc:date>2021-10-14T11:42:14Z</dc:date>
    </item>
  </channel>
</rss>

