<?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: Passing output from DATA step to a PROC in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-columns-of-dummy-variables-that-correspond-to-each/m-p/473953#M121697</link>
    <description>&lt;P&gt;Hi Rick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much. This solution worked like a charm!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sincerely,&lt;/P&gt;
&lt;P&gt;Cuneyt&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jun 2018 02:00:33 GMT</pubDate>
    <dc:creator>Cuneyt</dc:creator>
    <dc:date>2018-06-28T02:00:33Z</dc:date>
    <item>
      <title>Find columns of dummy variables that correspond to each categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-columns-of-dummy-variables-that-correspond-to-each/m-p/473851#M121648</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using PROC SYSLIN with dummy variables generated by PROC GLMMOD. However, I must manually&amp;nbsp;intervene&amp;nbsp;as shown below:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" color="#000080"&gt;glmmod&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" color="#0000ff"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;=dataset1 &lt;/FONT&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;outdesign&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;=dummies &lt;/FONT&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; class&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; customer supplier;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* Each customer and supplier has a unique&amp;nbsp;number&amp;nbsp;*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; model&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;y = customer supplier; /* Generate dummy variables for customers&amp;nbsp;and suppliers&amp;nbsp;*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dataset2; /* Add dummy variables columns to the data set */&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dataset1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dummies;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;/* See which columns are for customers and which columns are for suppliers */&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color="#000080"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="Courier New" color="#000080"&gt;contents&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" color="#0000ff"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;=dataset2&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color="#000080"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;/* MANUALLY add customer and suppliers columns */&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" color="#000080"&gt;syslin&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" color="#0000ff"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;=dataset2 &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color="#008080"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;sls;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; endogenous&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; y1 y2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; instruments&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;w z &amp;nbsp;Col2-Col100 /*&amp;nbsp;assuming 100&amp;nbsp;customer and supplier dummies */;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt; customer: &lt;/FONT&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;model&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; y1 = w Col3 - Col61&amp;nbsp;&amp;nbsp; /* customer columns only */;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt; supplier: &lt;/FONT&gt;&lt;FONT face="Courier New" color="#0000ff"&gt;model&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;y2 = z Col63 - Col100 /*&amp;nbsp;supplier columns only */;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My questions is: How can I get the range of columns corresponding to customer and supplier dummies and pass that info as a macro variable to PROC SYSLIN? I do not want to hardcode the column numbers in PROC SYSLIN. Any help will be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sincerely,&lt;/P&gt;
&lt;P&gt;Cuneyt&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 09:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-columns-of-dummy-variables-that-correspond-to-each/m-p/473851#M121648</guid>
      <dc:creator>Cuneyt</dc:creator>
      <dc:date>2018-06-28T09:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Passing output from DATA step to a PROC</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-columns-of-dummy-variables-that-correspond-to-each/m-p/473944#M121692</link>
      <description>&lt;P&gt;In addition to the OUTDESIGN= option, which writes the dummy variables to a data set, you will want to use the&amp;nbsp;OUTPARM= option, which outputs a table that&amp;nbsp;connects the levels of the original variable to the names of the dummy variables. For an example, see the call to PROC GLMMOD in the article &lt;A href="https://blogs.sas.com/content/iml/2016/02/22/create-dummy-variables-in-sas.html" target="_self"&gt;"Create dummy variables in SAS."&lt;/A&gt;&amp;nbsp;&amp;nbsp;You can use a DATA step or PROC SQL to extract the column numbers for the&amp;nbsp;CUSTOMER and SUPPLIER variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the following uses&amp;nbsp;the SEX and BP_STATUS variables in the Sashelp.Heart data.&amp;nbsp; I am not familiar with PROC SYSLIN, but I use PROC MEANS to count the number of levels in each dummy variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glmmod data=sashelp.heart outdesign=GLMDesign outparm=GLMParm noprint;
   class sex BP_Status;
   model Cholesterol = Sex BP_Status;
run;
 
data _NULL_;
set GLMParm(where=(EFFNAME^="Intercept"));
by notsorted EFFNAME;
if first.EFFNAME then do;
   macroName = catt(EFFNAME, "Min");
   call symputx(macroName, _COLNUM_);
end;
if last.EFFNAME then do;
   macroName = catt(EFFNAME, "Max");
   call symputx(macroName, _COLNUM_);
end;
run;
 
%put &amp;amp;=SexMin;       /* first column for SEX */
%put &amp;amp;=SexMax;       /* last column for SEX */
%put &amp;amp;=BP_StatusMin; /* first column for BP_STATUS */
%put &amp;amp;=BP_StatusMax; /* last column for BP_STATUS */

proc means data=GLMDesign sum;
var COL&amp;amp;SexMin - COL&amp;amp;SexMax
    COL&amp;amp;BP_StatusMin - COL&amp;amp;BP_StatusMax;
run;

/* should give the same counts as PROC FREQ */
/*
proc freq data=Sashelp.Heart(where=(Cholesterol^=.));
tables Sex BP_Status;
run;
*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jun 2018 00:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-columns-of-dummy-variables-that-correspond-to-each/m-p/473944#M121692</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-06-28T00:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Passing output from DATA step to a PROC</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-columns-of-dummy-variables-that-correspond-to-each/m-p/473953#M121697</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much. This solution worked like a charm!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sincerely,&lt;/P&gt;
&lt;P&gt;Cuneyt&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 02:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-columns-of-dummy-variables-that-correspond-to-each/m-p/473953#M121697</guid>
      <dc:creator>Cuneyt</dc:creator>
      <dc:date>2018-06-28T02:00:33Z</dc:date>
    </item>
  </channel>
</rss>

