<?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: How to code for many regression models with repeating variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96125#M257740</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi TJ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't tested the attached as you haven't provided any data, but hopefully it makes sense.&amp;nbsp; If you have each of your scenarios in a dataset, which I assume you can achieve on your own, using a Call Execute will allow for you to use values in the relevant variables as part of your statements, functions and the like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;SET SAMPLES (END=EOF);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STR =COMPBL( "PROC LOGISTIC DATA = HAVE; MODEL "|| SITE || " (EVENT='1')=" || EXP || ";";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL EXECUTE (STR);&lt;/P&gt;&lt;P&gt;IF EOF THEN DO;&lt;/P&gt;&lt;P&gt;STR = 'RUN;';&lt;/P&gt;&lt;P&gt;CALL EXECUTE (STR);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following gives you a simple example of code that works.&amp;nbsp; We are accessing the Dictionary View VCOLUMN to identify all the columns in SASHELP.CLASS and executing a sort on each of the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;SET SASHELP.VCOLUMN (WHERE =(LIBNAME = "SASHELP" AND MEMNAME = "CLASS")) END=EOF;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STR =COMPBL( "PROC SORT DATA = SASHELP.CLASS OUT = SORTCLASS ; BY " || NAME || ";");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL EXECUTE (STR);&lt;/P&gt;&lt;P&gt;IF EOF THEN DO;&lt;/P&gt;&lt;P&gt;STR = 'RUN;';&lt;/P&gt;&lt;P&gt;CALL EXECUTE (STR);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Aug 2013 01:03:05 GMT</pubDate>
    <dc:creator>Scott_Mitchell</dc:creator>
    <dc:date>2013-08-01T01:03:05Z</dc:date>
    <item>
      <title>How to code for many regression models with similar variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96124#M257739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to calculate logistic regression odds ratios (associations) between 20 different chemicals and 9 different cancer sites in my dataset.&lt;/P&gt;&lt;P&gt;I would like to use macro language or proc sql to efficiently code for the 180 logistic regression models.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My variables are person id (ID), sites A-I (site), and chemical exposures 1-20 (exp). Here is an idea of what my data looks like.&amp;nbsp; The variables for cancer sites are coded as dummy variables (1= case, 0=non-case).&amp;nbsp; &lt;/P&gt;&lt;P&gt;The ellipsis (...) indicates that I'm only showing 1 cancer site variable instead of all 9, only 1 chemical out of 20, and only 5 subjects from the whole study.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SiteA ...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exp1 ... &lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10.5&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.3&lt;/P&gt;&lt;P&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12.2&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My basic model looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc logistic data = analysis;&lt;/P&gt;&lt;P&gt;model &amp;amp;site (event="1")= &amp;amp;exp; *Odds ratios for chemicals as continuous variables;&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could someone please suggest how I can write concise code for all these tests using the same underlying model? Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Jul 2013 23:25:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96124#M257739</guid>
      <dc:creator>TJ87</dc:creator>
      <dc:date>2013-07-31T23:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to code for many regression models with repeating variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96125#M257740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi TJ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't tested the attached as you haven't provided any data, but hopefully it makes sense.&amp;nbsp; If you have each of your scenarios in a dataset, which I assume you can achieve on your own, using a Call Execute will allow for you to use values in the relevant variables as part of your statements, functions and the like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;SET SAMPLES (END=EOF);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STR =COMPBL( "PROC LOGISTIC DATA = HAVE; MODEL "|| SITE || " (EVENT='1')=" || EXP || ";";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL EXECUTE (STR);&lt;/P&gt;&lt;P&gt;IF EOF THEN DO;&lt;/P&gt;&lt;P&gt;STR = 'RUN;';&lt;/P&gt;&lt;P&gt;CALL EXECUTE (STR);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following gives you a simple example of code that works.&amp;nbsp; We are accessing the Dictionary View VCOLUMN to identify all the columns in SASHELP.CLASS and executing a sort on each of the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;SET SASHELP.VCOLUMN (WHERE =(LIBNAME = "SASHELP" AND MEMNAME = "CLASS")) END=EOF;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STR =COMPBL( "PROC SORT DATA = SASHELP.CLASS OUT = SORTCLASS ; BY " || NAME || ";");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL EXECUTE (STR);&lt;/P&gt;&lt;P&gt;IF EOF THEN DO;&lt;/P&gt;&lt;P&gt;STR = 'RUN;';&lt;/P&gt;&lt;P&gt;CALL EXECUTE (STR);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 01:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96125#M257740</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-08-01T01:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to code for many regression models with repeating variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96126#M257741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your suggested code. I found&lt;A href="http://www.scsug.org/SCSUGProceedings/2011/vidras1/PROC_LOGISTIC_SAS_MACROS_and_ODS_Output.pdf"&gt; this link&lt;/A&gt; to be especially helpful for testing multiple independent variables. The authors also run the 'call execute' subroutine that you recommend.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jan 2014 18:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96126#M257741</guid>
      <dc:creator>TJ87</dc:creator>
      <dc:date>2014-01-20T18:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to code for many regression models with similar variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96127#M257742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps I'm missing something, but if you just want 9 different independent analyses, transform the data into a long data set with SITE=A-I and use a BY statement with SITE as the BY variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to specify a single model that incorporates the sites, you can specify SITE as a CLASS variable and include interactions between the variables and the sites.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lastly, if SITE is a random variable, rather than a fixed effect, you might want to look at using PROC GLIMMIX instead of PROC LOGISTIC. &lt;A __default_attr="455729" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; has posted many examples of using PROC GLIMMIX.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2014 14:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-for-many-regression-models-with-similar-variables/m-p/96127#M257742</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-01-21T14:58:36Z</dc:date>
    </item>
  </channel>
</rss>

