<?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: iterative macro to drop variables from model with high VIF systemically in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/232810#M12264</link>
    <description>&lt;P&gt;Oh. Sorry. I'm new to posting in a community. Usually I just google my way to an answer from the SAS website, but this one has been rough. This is what I've done thus far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; MULTICOLLINEARITY(YVAR,FIELDS,MAX_VIF);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ods _all_ close;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; Running with &amp;amp;fields; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC REG DATA=save.dafinal;&lt;/P&gt;&lt;P&gt;MODEL &amp;amp;YVAR = &amp;amp;FIELDS / VIF COLLIN NOINT;&lt;/P&gt;&lt;P&gt;ODS OUTPUT PARAMETERESTIMATES=PAREST2;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=parest2;&lt;/P&gt;&lt;P&gt;by descending varianceinflation;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;set parest2(obs=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;if varianceinflation &amp;gt; &amp;amp;max_vif then do;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;fields_run = tranwrd(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;fields"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,trim(variable),&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;if not missing(fields_run) then do;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;call_string = cats(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'%multicollinearity('&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;yvar.,"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,fields_run,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;",&amp;amp;max_vif.)"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;call execute(call_string);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else do;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;put &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Stopped with Max VIF:"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; variable &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"="&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; varianceinflation;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;ods preferences;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; MULTICOLLINEARITY;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;MULTICOLLINEARITY&lt;/I&gt;&lt;/STRONG&gt;(yvar=gaaverage, fields=%&lt;STRONG&gt;&lt;I&gt;radius1demovars&lt;/I&gt;&lt;/STRONG&gt;,MAX_VIF=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;5&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Nov 2015 20:54:01 GMT</pubDate>
    <dc:creator>thetwudu</dc:creator>
    <dc:date>2015-11-02T20:54:01Z</dc:date>
    <item>
      <title>iterative macro to drop variables from model with high VIF systemically</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/232792#M12260</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a macro that will drop variables from my regression model, one at a time, based on VIF. I want it to run, drop the highest VIF variable, run again, drop the highest, then repeat until all VIFs are 5 or less. Please help. My data set is named "save.dafinal", dependent variable is "gaaverage", and independent variables are saved as a macro variable "%radius1demo". Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 19:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/232792#M12260</guid>
      <dc:creator>thetwudu</dc:creator>
      <dc:date>2015-11-02T19:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: iterative macro to drop variables from model with high VIF systemically</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/232800#M12261</link>
      <description>Your question is coming across as "Do my work" rather than "I need help", In general, if you need someone to do work, you hire a consultant. &lt;BR /&gt;&lt;BR /&gt;What have you tried? Where are you having issues?</description>
      <pubDate>Mon, 02 Nov 2015 20:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/232800#M12261</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-02T20:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: iterative macro to drop variables from model with high VIF systemically</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/232810#M12264</link>
      <description>&lt;P&gt;Oh. Sorry. I'm new to posting in a community. Usually I just google my way to an answer from the SAS website, but this one has been rough. This is what I've done thus far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; MULTICOLLINEARITY(YVAR,FIELDS,MAX_VIF);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ods _all_ close;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; Running with &amp;amp;fields; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC REG DATA=save.dafinal;&lt;/P&gt;&lt;P&gt;MODEL &amp;amp;YVAR = &amp;amp;FIELDS / VIF COLLIN NOINT;&lt;/P&gt;&lt;P&gt;ODS OUTPUT PARAMETERESTIMATES=PAREST2;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=parest2;&lt;/P&gt;&lt;P&gt;by descending varianceinflation;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;set parest2(obs=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;if varianceinflation &amp;gt; &amp;amp;max_vif then do;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;fields_run = tranwrd(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;fields"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,trim(variable),&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;if not missing(fields_run) then do;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;call_string = cats(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'%multicollinearity('&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;yvar.,"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,fields_run,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;",&amp;amp;max_vif.)"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;call execute(call_string);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else do;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;put &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Stopped with Max VIF:"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; variable &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"="&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; varianceinflation;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;ods preferences;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; MULTICOLLINEARITY;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;MULTICOLLINEARITY&lt;/I&gt;&lt;/STRONG&gt;(yvar=gaaverage, fields=%&lt;STRONG&gt;&lt;I&gt;radius1demovars&lt;/I&gt;&lt;/STRONG&gt;,MAX_VIF=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;5&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 20:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/232810#M12264</guid>
      <dc:creator>thetwudu</dc:creator>
      <dc:date>2015-11-02T20:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: iterative macro to drop variables from model with high VIF systemically</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/587739#M28773</link>
      <description>&lt;P&gt;/* Author PRAKASH HULLATHI */&lt;BR /&gt;/*CREATING THE DATA FOR MULTICOLLINEARITY*/&lt;/P&gt;&lt;P&gt;%MACRO REMOVE_MULTICOLLINEARITY(DATASET=,YVAR=,VIF_CUTOFF=);&lt;/P&gt;&lt;P&gt;/*taking output of all variables*/&lt;BR /&gt;PROC CONTENTS DATA=&amp;amp;DATASET. VARNUM OUT=T;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*filter only numeric variables excluding dependent and date variables*/&lt;BR /&gt;DATA T1;&lt;BR /&gt;SET T;&lt;BR /&gt;KEEP NAME ;&lt;BR /&gt;WHERE TYPE=1 AND NAME NOT IN("&amp;amp;yvar.") and FORMAT not in('DATE') ;/* Remove target and date variables*/&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*creating macro for independent variables*/&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT NAME INTO : XVARS SEPARATED BY ' '&lt;BR /&gt;FROM T1;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;%PUT independent_variables=&amp;amp;XVARS;&lt;/P&gt;&lt;P&gt;/*running the regression model till independent variables vif&amp;lt; specified vif_cutoff*/&lt;BR /&gt;%DO %UNTIL (%SYSEVALF(&amp;amp;MAX_VIF.&amp;lt;=&amp;amp;VIF_CUTOFF.) );&lt;/P&gt;&lt;P&gt;/*taking the output of independent variables vif by removing the intercept*/&lt;BR /&gt;ODS OUTPUT PARAMETERESTIMATES=PAREST2;&lt;/P&gt;&lt;P&gt;PROC REG DATA=&amp;amp;DATASET. ;&lt;/P&gt;&lt;P&gt;MODEL &amp;amp;YVAR.= &amp;amp;XVARS. / VIF ;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;/*dropping the independent variables with missing vif value*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA T11;&lt;BR /&gt;SET PAREST2;&lt;BR /&gt;IF VarianceInflation NOT IN(.) ;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*sorting the vif value by descending order*/&lt;BR /&gt;PROC SORT DATA=PAREST2 OUT=PAREST2_SORT ;&lt;BR /&gt;BY DESCENDING VarianceInflation;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*considering the highest vif value */&lt;BR /&gt;DATA PAREST2_SORT_2;&lt;BR /&gt;SET PAREST2_SORT;&lt;BR /&gt;IF _N_=1;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*creating the macro for highest vif value*/&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT VARIABLE INTO: REMOVE_VAR&lt;BR /&gt;FROM PAREST2_SORT_2;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;/*dropping the highest vif value variable*/&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT ;&lt;BR /&gt;SELECT Variable INTO: XVARS SEPARATED BY ' '&lt;BR /&gt;FROM T11&lt;BR /&gt;WHERE VARIABLE NOT IN("&amp;amp;REMOVE_VAR.","Intercept") ;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;/*getiing the highest vif value*/&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT MAX(VarianceInflation) INTO: MAX_VIF&lt;BR /&gt;FROM PAREST2;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;%PUT max_vif=&amp;amp;MAX_VIF. variable_removed=&amp;amp;REMOVE_VAR. ;&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;%MEND REMOVE_MULTICOLLINEARITY;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%REMOVE_MULTICOLLINEARITY(DATASET=sashelp.cars,YVAR=MPG_City,VIF_CUTOFF=10)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* after running the above sas macro code&lt;BR /&gt;for multicollinearity then run the below code */&lt;/P&gt;&lt;P&gt;/* final data set with no multicollinearity variables*/&lt;BR /&gt;data NO_MULTICOLLINEARITY;&lt;BR /&gt;SET PAREST2;&lt;BR /&gt;KEEP VARIABLE;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT VARIABLE INTO : XVARS_final SEPARATED BY ' '&lt;BR /&gt;FROM NO_MULTICOLLINEARITY&lt;BR /&gt;WHERE VARIABLE NOT IN("Intercept");&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;PROC REG DATA=SASHELP.CARS;&lt;BR /&gt;MODEL MPG_City=&amp;amp;XVARS_final./ VIF ;&lt;BR /&gt;RUN;&lt;BR /&gt;QUIT;&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>Sun, 15 Sep 2019 06:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/587739#M28773</guid>
      <dc:creator>phullathi</dc:creator>
      <dc:date>2019-09-15T06:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: iterative macro to drop variables from model with high VIF SYQUENTIALLY</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/588182#M28793</link>
      <description>&lt;P&gt;/* Author PRAKASH HULLATHI */&lt;BR /&gt;/*CREATING THE DATA FOR MULTICOLLINEARITY*/&lt;/P&gt;&lt;P&gt;%MACRO REMOVE_MULTICOLLINEARITY(DATASET=,YVAR=,VIF_CUTOFF=);&lt;/P&gt;&lt;P&gt;/*taking output of all variables*/&lt;BR /&gt;PROC CONTENTS DATA=&amp;amp;DATASET. VARNUM OUT=T;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*filter only numeric variables excluding dependent and date variables*/&lt;BR /&gt;DATA T1;&lt;BR /&gt;SET T;&lt;BR /&gt;KEEP NAME ;&lt;BR /&gt;WHERE TYPE=1 AND NAME NOT IN("&amp;amp;yvar.") and FORMAT not in('DATE') ;/* Remove target and date variables*/&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*creating macro for independent variables*/&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT NAME INTO : XVARS SEPARATED BY ' '&lt;BR /&gt;FROM T1;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;%PUT independent_variables=&amp;amp;XVARS;&lt;/P&gt;&lt;P&gt;/*running the regression model till independent variables vif&amp;lt; specified vif_cutoff*/&lt;BR /&gt;%DO %UNTIL (%SYSEVALF(&amp;amp;MAX_VIF.&amp;lt;=&amp;amp;VIF_CUTOFF.) );&lt;/P&gt;&lt;P&gt;/*taking the output of independent variables vif by removing the intercept*/&lt;BR /&gt;ODS OUTPUT PARAMETERESTIMATES=PAREST2;&lt;/P&gt;&lt;P&gt;PROC REG DATA=&amp;amp;DATASET. ;&lt;/P&gt;&lt;P&gt;MODEL &amp;amp;YVAR.= &amp;amp;XVARS. / VIF ;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;/*dropping the independent variables with missing vif value*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA T11;&lt;BR /&gt;SET PAREST2;&lt;BR /&gt;IF VarianceInflation NOT IN(.) ;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*sorting the vif value by descending order*/&lt;BR /&gt;PROC SORT DATA=PAREST2 OUT=PAREST2_SORT ;&lt;BR /&gt;BY DESCENDING VarianceInflation;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*considering the highest vif value */&lt;BR /&gt;DATA PAREST2_SORT_2;&lt;BR /&gt;SET PAREST2_SORT;&lt;BR /&gt;IF _N_=1;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*creating the macro for highest vif value*/&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT VARIABLE INTO: REMOVE_VAR&lt;BR /&gt;FROM PAREST2_SORT_2;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;/*dropping the highest vif value variable*/&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT ;&lt;BR /&gt;SELECT Variable INTO: XVARS SEPARATED BY ' '&lt;BR /&gt;FROM T11&lt;BR /&gt;WHERE VARIABLE NOT IN("&amp;amp;REMOVE_VAR.","Intercept") ;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;/*getiing the highest vif value*/&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT MAX(VarianceInflation) INTO: MAX_VIF&lt;BR /&gt;FROM PAREST2;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;%PUT max_vif=&amp;amp;MAX_VIF. variable_removed=&amp;amp;REMOVE_VAR. ;&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;%MEND REMOVE_MULTICOLLINEARITY;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%REMOVE_MULTICOLLINEARITY(DATASET=sashelp.cars,YVAR=MPG_City,VIF_CUTOFF=10)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* after running the above sas macro code&lt;BR /&gt;for multicollinearity then run the below code */&lt;/P&gt;&lt;P&gt;/* final data set with no multicollinearity variables*/&lt;BR /&gt;data NO_MULTICOLLINEARITY;&lt;BR /&gt;SET PAREST2;&lt;BR /&gt;KEEP VARIABLE;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT VARIABLE INTO : XVARS_final SEPARATED BY ' '&lt;BR /&gt;FROM NO_MULTICOLLINEARITY&lt;BR /&gt;WHERE VARIABLE NOT IN("Intercept");&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;PROC REG DATA=SASHELP.CARS;&lt;BR /&gt;MODEL MPG_City=&amp;amp;XVARS_final./ VIF ;&lt;BR /&gt;RUN;&lt;BR /&gt;QUIT;&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>Sun, 15 Sep 2019 06:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/588182#M28793</guid>
      <dc:creator>phullathi</dc:creator>
      <dc:date>2019-09-15T06:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: iterative macro to drop variables from model with high VIF SYQUENTIALLY</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/588224#M28796</link>
      <description>It's not common to reply to a 4 year old thread. Are you providing an answer here or trying to ask a question?</description>
      <pubDate>Thu, 12 Sep 2019 13:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/588224#M28796</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-12T13:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: iterative macro to drop variables from model with high VIF SYQUENTIALLY</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/588802#M28817</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am providing the correct solution for removing multicollinearity sequentially.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Prakash Hullathi&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2019 06:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/iterative-macro-to-drop-variables-from-model-with-high-VIF/m-p/588802#M28817</guid>
      <dc:creator>phullathi</dc:creator>
      <dc:date>2019-09-15T06:57:32Z</dc:date>
    </item>
  </channel>
</rss>

