<?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 Writing a macro for many univariate analysis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825390#M326030</link>
    <description>&lt;P&gt;I am currently building a multiple logistic regression, Before that, I will do univariate analysis for each variable including both categorical and continuous data (around 20~). I am doing a macro to help it more efficient. This is the code i am using now but this does not work and SAS log said : Libref E is not assigned. I wonder how i should adjust the code. Thank you!&lt;BR /&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let var = BMI air1 years etc. ;&lt;BR /&gt;%macro univar;&lt;BR /&gt;%do i=1 %to %eval(%sysfunc(countc(&amp;amp;var., " BMI air1 years etc."))+1);&lt;BR /&gt;%let var1 = %scan(&amp;amp;var, &amp;amp;i);&lt;BR /&gt;%put var1;&lt;BR /&gt;proc logistic descending data = e;&lt;BR /&gt;model cvs1 = &amp;amp;var1.;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jul 2022 04:31:38 GMT</pubDate>
    <dc:creator>Joseph0828</dc:creator>
    <dc:date>2022-07-26T04:31:38Z</dc:date>
    <item>
      <title>Writing a macro for many univariate analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825390#M326030</link>
      <description>&lt;P&gt;I am currently building a multiple logistic regression, Before that, I will do univariate analysis for each variable including both categorical and continuous data (around 20~). I am doing a macro to help it more efficient. This is the code i am using now but this does not work and SAS log said : Libref E is not assigned. I wonder how i should adjust the code. Thank you!&lt;BR /&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let var = BMI air1 years etc. ;&lt;BR /&gt;%macro univar;&lt;BR /&gt;%do i=1 %to %eval(%sysfunc(countc(&amp;amp;var., " BMI air1 years etc."))+1);&lt;BR /&gt;%let var1 = %scan(&amp;amp;var, &amp;amp;i);&lt;BR /&gt;%put var1;&lt;BR /&gt;proc logistic descending data = e;&lt;BR /&gt;model cvs1 = &amp;amp;var1.;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 04:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825390#M326030</guid>
      <dc:creator>Joseph0828</dc:creator>
      <dc:date>2022-07-26T04:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a macro for many univariate analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825417#M326043</link>
      <description>&lt;P&gt;First step to getting a macro to work ... create code without macros and without macro variables that works properly for one hard-coded instance of your problem. You haven't done this. If your code won't work without macros and without macro variables, then it most certainly will never work with macro variables and with macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, show me code that works without macros and without macro variables for one hard-coded instance of your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Furthermore, never show us a small portion of the messages in the log. Never show us errors in the macro out of context, we need to see the code that generated the error &lt;EM&gt;as it appears in the log&lt;/EM&gt;. Show us the &lt;FONT color="#FF0000"&gt;entire&lt;/FONT&gt; log for this macro (or if it is a large log, show us the 50 lines or so before the error).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above text is put forth for your future benefit whenever you decide to write a macro. There is no need to write macros for this problem, and the non-macro version will most likely be more efficient than the macro version. Please see:&amp;nbsp;&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;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 12:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825417#M326043</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-26T12:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a macro for many univariate analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825427#M326050</link>
      <description>&lt;P&gt;To count the number of words in a list use the COUNTW() function, not the COUNT() function.&lt;/P&gt;
&lt;P&gt;Remember to tell both %SCAN() and COUNTW() what delimiter you are using between the words in the list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to %sysfunc(countw(&amp;amp;var,%str( )));
  %let var1 = %scan(&amp;amp;var, &amp;amp;i,%str( ));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jul 2022 13:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825427#M326050</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-26T13:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a macro for many univariate analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825457#M326056</link>
      <description>&lt;P&gt;This page has the exact example you're trying to build about half way down the page.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.oarc.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.oarc.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 15:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-a-macro-for-many-univariate-analysis/m-p/825457#M326056</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-26T15:28:27Z</dc:date>
    </item>
  </channel>
</rss>

