<?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: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677309#M32509</link>
    <description>&lt;P&gt;To get ORs, you must have at least a 2 way TABLES statement. which is why you get what you want with your original code with the dummy variable.&amp;nbsp; That dummy variable sets hand/wrist as the incidence set and all other sites as the contrafactual set (to steal from the epidemiology nomenclature).&amp;nbsp; You could generate the multiple dummy variables using PROC GLMMOD, and then wrap your SURVEYFREQ code in a short macro loop to step through each of the dummy variables in turn.&amp;nbsp; There might be a way to use a BY statement, but I think you would still need to index the dummy variable to coincide with the BY variable.&amp;nbsp; This might be the rare case where looping would be superior to by processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
    <pubDate>Mon, 17 Aug 2020 17:29:45 GMT</pubDate>
    <dc:creator>SteveDenham</dc:creator>
    <dc:date>2020-08-17T17:29:45Z</dc:date>
    <item>
      <title>Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677110#M32489</link>
      <description>&lt;P&gt;I have a dataset that utilizes complex sampling to generate weighted injury counts across multiple sports. I am wanting to compare relative risk for boys' and girls' versions of the same sport, and do so across multiple variables, such as injury site. I can program SAS to do this one at a time with a dummy variable (see example below) but would like to find a way to run them all at once (no odds ratios print; code from that failed attempt also below).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One-at-a-time:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data gender_ly_hand;
	set gender_ly;
	if injsite = "Hand/Wrist" then dum = 1;
	else dum = 0;
run; 

/* this works (column 2 risk), but would have to do for every variable individually */
proc surveyfreq data=gender_ly_hand;
   	strata strata;
	weight nationalweight;
	tables sport_name*dum/  or;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="panel1.png" style="width: 583px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48289i989B0823AFCA414F/image-size/large?v=v2&amp;amp;px=999" role="button" title="panel1.png" alt="panel1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Failed attempt at all-at-once:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyfreq data=gender_ly;
   	strata strata;
	weight nationalweight;
	tables sport_name*injsite/  or;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="panel2.png" style="width: 703px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48290i339A7BA99FE8FCA4/image-size/large?v=v2&amp;amp;px=999" role="button" title="panel2.png" alt="panel2.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Aug 2020 21:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677110#M32489</guid>
      <dc:creator>tburus</dc:creator>
      <dc:date>2020-08-16T21:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677116#M32490</link>
      <description>You want to add a BY statement. You want it for each Site, not by site. &lt;BR /&gt;&lt;BR /&gt;proc surveyfreq data=gender_LY;&lt;BR /&gt;       by injsite;&lt;BR /&gt;   	strata strata;&lt;BR /&gt;	weight nationalweight;&lt;BR /&gt;	tables sport_name/  or;&lt;BR /&gt;run;</description>
      <pubDate>Sun, 16 Aug 2020 22:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677116#M32490</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-16T22:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677119#M32491</link>
      <description>&lt;P&gt;This is what I get when I run that code (repeats for each injury site). No odds ratios print out.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plot.png" style="width: 492px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48291i56C95E3BA54690B4/image-size/large?v=v2&amp;amp;px=999" role="button" title="plot.png" alt="plot.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Aug 2020 22:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677119#M32491</guid>
      <dc:creator>tburus</dc:creator>
      <dc:date>2020-08-16T22:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677273#M32505</link>
      <description>Try adding the INJSITE to the table statement as well.</description>
      <pubDate>Mon, 17 Aug 2020 15:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677273#M32505</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-17T15:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677277#M32506</link>
      <description>&lt;P&gt;SAS is not happy with injsite being in both the BY and TABLES statements.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 15:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677277#M32506</guid>
      <dc:creator>tburus</dc:creator>
      <dc:date>2020-08-17T15:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677309#M32509</link>
      <description>&lt;P&gt;To get ORs, you must have at least a 2 way TABLES statement. which is why you get what you want with your original code with the dummy variable.&amp;nbsp; That dummy variable sets hand/wrist as the incidence set and all other sites as the contrafactual set (to steal from the epidemiology nomenclature).&amp;nbsp; You could generate the multiple dummy variables using PROC GLMMOD, and then wrap your SURVEYFREQ code in a short macro loop to step through each of the dummy variables in turn.&amp;nbsp; There might be a way to use a BY statement, but I think you would still need to index the dummy variable to coincide with the BY variable.&amp;nbsp; This might be the rare case where looping would be superior to by processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 17:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677309#M32509</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2020-08-17T17:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677317#M32510</link>
      <description>&lt;P&gt;Okay. So this gets it done (but is a terrible solution from a practical standpoint given what I'm needing it for—don't know that anything can be done about that).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO DO_LIST;
%DO i = 4 %TO 15;
proc surveyfreq data=GLMDesign;
   	strata strata;
	weight nationalweight;
	tables col2*col&amp;amp;i./ or;
run;
%END;
%MEND DO_LIST;
%DO_LIST;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Next, then, would be, how can I get it to capture the column 2 relative risk estimates and CI limits for each iteration of PROC SURVEYFREQ?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 17:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677317#M32510</guid>
      <dc:creator>tburus</dc:creator>
      <dc:date>2020-08-17T17:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677325#M32511</link>
      <description>Ah...you're testing each sub population against the rest of the population so that won't work. You don't have a ton of observations (800) so making a big table against all is probably a decent option. To store tables look at the ODS statement and then the PERSIST option if you want to loop through and keep that in the data.</description>
      <pubDate>Mon, 17 Aug 2020 18:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677325#M32511</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-17T18:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677327#M32512</link>
      <description>&lt;P&gt;So, this works. I kind of hate SAS! Thanks for the help everyone.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO so_injsite;
ods output OddsRatio(persist=proc)=odds(where=(Statistic="Column 2 Relative Risk"));
%DO i = 4 %TO 15;
proc surveyfreq data=GLMDesign;
   	strata strata;
	weight nationalweight;
	tables col2*col&amp;amp;i./ or;
run;
%END;
ods output close;
%MEND so_injsite;
%so_injsite&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Aug 2020 18:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677327#M32512</guid>
      <dc:creator>tburus</dc:creator>
      <dc:date>2020-08-17T18:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677334#M32513</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output OddsRatio(persist=proc)=odds(where=(Statistic="Column 2 Relative Risk"));
proc surveyfreq data=GLMDesign;
   	strata strata;
	weight nationalweight;
	tables col2 * (col4-col15)/ or;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't think you needed a macro, you needed the dummy variables though....does the above code work for you as well?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 19:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677334#M32513</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-17T19:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677378#M32516</link>
      <description>&lt;P&gt;Yes, this is perfect. I didn't realize I could do this; that's exactly what I was hoping was possible.&lt;/P&gt;
&lt;P&gt;Just as a follow up, is that (col4-col15) syntax a standard shorthand in other SAS PROCs for some sort of distributive property on running multiple iterations? That could be helpful elsewhere.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 02:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677378#M32516</guid>
      <dc:creator>tburus</dc:creator>
      <dc:date>2020-08-18T02:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677383#M32517</link>
      <description>&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 03:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677383#M32517</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-18T03:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple PROC SURVEY FREQs to Get Relative Risk CIs</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677442#M32523</link>
      <description>&lt;P&gt;Hats off to you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for presenting a simple answer to something I had made more complicated than needed.&amp;nbsp; I wish I could give more than 1 like...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 11:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Running-Multiple-PROC-SURVEY-FREQs-to-Get-Relative-Risk-CIs/m-p/677442#M32523</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2020-08-18T11:49:44Z</dc:date>
    </item>
  </channel>
</rss>

