<?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: Iteratively running a procedure, substituting variables from a list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779564#M248303</link>
    <description>&lt;P&gt;To tell you the truth, I was thinking year should be a CLASS variable if you are doing a study with random sampling over many years. But I don't know your data. And I don't know your study design.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, there's no way I can tell what PROC you should be using since I don't know what VAR1 is. For PROC SURVEYLOGISTIC, you need to have VAR1 as categories. If VAR1 is continuous, then you would want to use PROC SURVEYREG.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Nov 2021 14:29:11 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-11-10T14:29:11Z</dc:date>
    <item>
      <title>Iteratively running a procedure, substituting variables from a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779555#M248296</link>
      <description>&lt;P&gt;I'm trying to run a simple&amp;nbsp;&lt;EM&gt;proc surveylogistic&lt;/EM&gt; using one variable at a time to retrieve trends overtime for each variable. I don't want to have to copy/paste the variables each time and re-run (there are 55 of them, total). So I thought about creating an ARRAY containing the list of variables, and telling SAS to iterate through that list, one at a time, then finally print each of those "final outputs" into the results window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I'm not sure how to do this. Or if there is a better option, considering I have to create the ARRAY in the data step, then somehow pass it to the proc step? Below is an example of what I've been attempting, based off a suggestion I saw elsewhere on another forum:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create array list;&lt;BR /&gt;ARRAY roll	[4]	
var1 var2 var3 var4;

DO i=1 to 4;
&lt;BR /&gt;    *Select only table of interest;
	ODS Select  ParameterEstimates;
	ODS output  ParameterEstimates= roll[i];
	PROC SURVEYLOGISTIC Data=rollrpt3 Total=TOTALS_DATASET NOMCAR;																		
	Weight wghtvar;
	Strata strat_var;
		Model roll[4] = year;
	Run;  
	ODS close;

	*Print estimate and its associated P-value for trend;
	Proc print data=roll[i];
	Var Variable ProbT;
	Where Variable="year";
	run;
Quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 14:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779555#M248296</guid>
      <dc:creator>SAS93</dc:creator>
      <dc:date>2021-11-10T14:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively running a procedure, substituting variables from a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779558#M248299</link>
      <description>&lt;P&gt;You could use a macro, such as this example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let varnames=var1 var2 var3 var4;
%macro dothis;
    %do i=1 %to %sysfunc(countw(&amp;amp;varnames));
         %let thisname=%scan(&amp;amp;varnames,&amp;amp;i,%str( ));
         proc surveylogistic data=rollrpt3 /* whatever other options you want */ ;
               model &amp;amp;thisname = year;
               /* Any other needed statements in PROC SURVEYLOGISTIC */
          run;
     %end;
%mend;
%dothis&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am skeptical that SURVEYLOGISTIC is a good tool to model a variable named YEAR as a predictor variable. But I don't know the goals of this study ... why don't you tell us the goals?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 14:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779558#M248299</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-10T14:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively running a procedure, substituting variables from a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779559#M248300</link>
      <description>Thank you for the suggestion! I'm using survey data to assess change in overall prevalence of various dichotomous indicators (the variables in my list) over a continuous variable for time (years) instead of setting it as categorical. The prevalence estimates need to be properly weighted, so survey procedures it is. &lt;BR /&gt;Would you recommend using surveyREG instead of logistic?</description>
      <pubDate>Wed, 10 Nov 2021 14:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779559#M248300</guid>
      <dc:creator>SAS93</dc:creator>
      <dc:date>2021-11-10T14:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Iteratively running a procedure, substituting variables from a list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779564#M248303</link>
      <description>&lt;P&gt;To tell you the truth, I was thinking year should be a CLASS variable if you are doing a study with random sampling over many years. But I don't know your data. And I don't know your study design.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, there's no way I can tell what PROC you should be using since I don't know what VAR1 is. For PROC SURVEYLOGISTIC, you need to have VAR1 as categories. If VAR1 is continuous, then you would want to use PROC SURVEYREG.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 14:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iteratively-running-a-procedure-substituting-variables-from-a/m-p/779564#M248303</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-10T14:29:11Z</dc:date>
    </item>
  </channel>
</rss>

