<?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: List variables by condition from Excel sheet to run thousands of univariate regression in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663568#M198102</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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can very easy build a dynamic list but see the shortcut approaches above to see if any work for you to fix your array statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The other method is to query sashelp.vcolumns or dictionary.colums which has the metadata about your data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/160501"&gt;@mh2t&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have 2 datasets; an original dataset formatted in SAS (5M x 10000), and an Excel sheet which contains variables' names and their statistics summary (10000 x 7). I&amp;nbsp;&lt;SPAN&gt;want to compute around 5000 single-variable regression models of the form Y=X&lt;/SPAN&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;SPAN&gt;, where&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;= 1 to 5000. Those 5000 variables are selected by conditioning on particular columns (like if 5 &amp;lt; nLevels &amp;lt; 40 AND nMissing &amp;lt; 10000) in the Excel sheet. My variables' names do not have a common pattern. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I could find the &lt;A href="https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html" target="_self"&gt;code&lt;/A&gt; for computing many&amp;nbsp;single-variable regression models, but I don't know how to list the subset of variables by condition from Excel sheet:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* 1. transpose from wide (Y, X1 ,...,X10000) to long (varNum VarName Y Value) */
data Long;
set Wide;                       
array x [*] x1-x&amp;amp;nCont;         /* &amp;lt;== I want this list to be read from Excel sheet &lt;BR /&gt;                                       by conditioning */
do varNum = 1 to dim(x);
   VarName = vname(x[varNum]);  /* variable name in char var */
   Value = x[varNum];           /* value for each variable for each obs */
   output;
end;
drop x:;
run;&lt;/PRE&gt;
&lt;PRE class="sas"&gt;&lt;SPAN&gt;/* 2. Sort by BY-group variable */&lt;/SPAN&gt;
&lt;SPAN&gt;proc sort&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=Long;  &lt;SPAN&gt;by&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt;;  &lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;PRE class="sas"&gt;&lt;SPAN&gt;/* 3. Call PROC REG and use BY statement to compute all regressions */&lt;/SPAN&gt;
&lt;SPAN&gt;proc reg&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=Long noprint outest=PE;
&lt;SPAN&gt;by&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt;;
model Y = Value;
&lt;SPAN&gt;quit&lt;/SPAN&gt;;
&amp;nbsp;
&lt;SPAN&gt;/* Look at the results */&lt;/SPAN&gt;
&lt;SPAN&gt;proc print&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=PE&lt;SPAN&gt;(&lt;/SPAN&gt;obs=&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;;
&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt; Intercept Value;
&lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; I'm very new to SAS and any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jun 2020 19:07:07 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-06-19T19:07:07Z</dc:date>
    <item>
      <title>List variables by condition from Excel sheet to run thousands of univariate regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663567#M198101</link>
      <description>&lt;P&gt;I have 2 datasets; an original dataset formatted in SAS (5M x 10000), and an Excel sheet which contains variables' names and their statistics summary (10000 x 7). I&amp;nbsp;&lt;SPAN&gt;want to compute around 5000 single-variable regression models of the form Y=X&lt;/SPAN&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;SPAN&gt;, where&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;= 1 to 5000. Those 5000 variables are selected by conditioning on particular columns (like if 5 &amp;lt; nLevels &amp;lt; 40 AND nMissing &amp;lt; 10000) in the Excel sheet. My variables' names do not have a common pattern. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I could find the &lt;A href="https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html" target="_self"&gt;code&lt;/A&gt; for computing many&amp;nbsp;single-variable regression models, but I don't know how to list the subset of variables by condition from Excel sheet:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* 1. transpose from wide (Y, X1 ,...,X10000) to long (varNum VarName Y Value) */
data Long;
set Wide;                       
array x [*] x1-x&amp;amp;nCont;         /* &amp;lt;== I want this list to be read from Excel sheet &lt;BR /&gt;                                       by conditioning */
do varNum = 1 to dim(x);
   VarName = vname(x[varNum]);  /* variable name in char var */
   Value = x[varNum];           /* value for each variable for each obs */
   output;
end;
drop x:;
run;&lt;/PRE&gt;&lt;PRE class="sas"&gt;&lt;SPAN&gt;/* 2. Sort by BY-group variable */&lt;/SPAN&gt;
&lt;SPAN&gt;proc sort&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=Long;  &lt;SPAN&gt;by&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt;;  &lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class="sas"&gt;&lt;SPAN&gt;/* 3. Call PROC REG and use BY statement to compute all regressions */&lt;/SPAN&gt;
&lt;SPAN&gt;proc reg&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=Long noprint outest=PE;
&lt;SPAN&gt;by&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt;;
model Y = Value;
&lt;SPAN&gt;quit&lt;/SPAN&gt;;
&amp;nbsp;
&lt;SPAN&gt;/* Look at the results */&lt;/SPAN&gt;
&lt;SPAN&gt;proc print&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=PE&lt;SPAN&gt;(&lt;/SPAN&gt;obs=&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;;
&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt; Intercept Value;
&lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; I'm very new to SAS and any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 18:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663567#M198101</guid>
      <dc:creator>mh2t</dc:creator>
      <dc:date>2020-06-19T18:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: List variables by condition from Excel sheet to run thousands of univariate regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663568#M198102</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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can very easy build a dynamic list but see the shortcut approaches above to see if any work for you to fix your array statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The other method is to query sashelp.vcolumns or dictionary.colums which has the metadata about your data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/160501"&gt;@mh2t&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have 2 datasets; an original dataset formatted in SAS (5M x 10000), and an Excel sheet which contains variables' names and their statistics summary (10000 x 7). I&amp;nbsp;&lt;SPAN&gt;want to compute around 5000 single-variable regression models of the form Y=X&lt;/SPAN&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;SPAN&gt;, where&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;= 1 to 5000. Those 5000 variables are selected by conditioning on particular columns (like if 5 &amp;lt; nLevels &amp;lt; 40 AND nMissing &amp;lt; 10000) in the Excel sheet. My variables' names do not have a common pattern. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I could find the &lt;A href="https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html" target="_self"&gt;code&lt;/A&gt; for computing many&amp;nbsp;single-variable regression models, but I don't know how to list the subset of variables by condition from Excel sheet:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* 1. transpose from wide (Y, X1 ,...,X10000) to long (varNum VarName Y Value) */
data Long;
set Wide;                       
array x [*] x1-x&amp;amp;nCont;         /* &amp;lt;== I want this list to be read from Excel sheet &lt;BR /&gt;                                       by conditioning */
do varNum = 1 to dim(x);
   VarName = vname(x[varNum]);  /* variable name in char var */
   Value = x[varNum];           /* value for each variable for each obs */
   output;
end;
drop x:;
run;&lt;/PRE&gt;
&lt;PRE class="sas"&gt;&lt;SPAN&gt;/* 2. Sort by BY-group variable */&lt;/SPAN&gt;
&lt;SPAN&gt;proc sort&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=Long;  &lt;SPAN&gt;by&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt;;  &lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;PRE class="sas"&gt;&lt;SPAN&gt;/* 3. Call PROC REG and use BY statement to compute all regressions */&lt;/SPAN&gt;
&lt;SPAN&gt;proc reg&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=Long noprint outest=PE;
&lt;SPAN&gt;by&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt;;
model Y = Value;
&lt;SPAN&gt;quit&lt;/SPAN&gt;;
&amp;nbsp;
&lt;SPAN&gt;/* Look at the results */&lt;/SPAN&gt;
&lt;SPAN&gt;proc print&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;=PE&lt;SPAN&gt;(&lt;/SPAN&gt;obs=&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;;
&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;VarName&lt;/SPAN&gt; Intercept Value;
&lt;SPAN&gt;run&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; I'm very new to SAS and any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 19:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663568#M198102</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-19T19:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: List variables by condition from Excel sheet to run thousands of univariate regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663571#M198103</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for your response. How can I read variables from Excel sheet in proc sql?&lt;/P&gt;&lt;PRE&gt;proc sql noprint;                              
 select Variable into :MissingVarList separated by ' '
 from MissingValues  /* &amp;lt;=== should be read from Excel file */
 where NMiss &amp;gt; 0;
quit;
%put &amp;amp;=MissingVarList;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jun 2020 19:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663571#M198103</guid>
      <dc:creator>mh2t</dc:creator>
      <dc:date>2020-06-19T19:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: List variables by condition from Excel sheet to run thousands of univariate regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663572#M198104</link>
      <description>Assign a libname to your excel file and you treat it as a SAS data set.&lt;BR /&gt;&lt;BR /&gt;libname myData xlsx 'path to xlsx file';&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then your SQL sheet becomes:&lt;BR /&gt;from myData.Sheet1 &amp;lt;- reads from Sheet1 data set.</description>
      <pubDate>Fri, 19 Jun 2020 19:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663572#M198104</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-19T19:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: List variables by condition from Excel sheet to run thousands of univariate regression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663574#M198105</link>
      <description>Or import your Excel data (via PROC IMPORT) and it becomes a SAS data set you can query.</description>
      <pubDate>Fri, 19 Jun 2020 19:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-variables-by-condition-from-Excel-sheet-to-run-thousands-of/m-p/663574#M198105</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-19T19:25:59Z</dc:date>
    </item>
  </channel>
</rss>

