<?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: Select Variables by Column Number Rather Than Name in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135684#M36670</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This almost does what I was hoping perfectly. One last step though is that I would like to put the output from each variable out into its own table. Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;TABLE &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;ColVar1&lt;/STRONG&gt; /OUT =T2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;TABLE &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;ColVar2&lt;/STRONG&gt; /OUT =T3;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Oct 2014 19:12:45 GMT</pubDate>
    <dc:creator>mikemangini</dc:creator>
    <dc:date>2014-10-21T19:12:45Z</dc:date>
    <item>
      <title>Select Variables by Column Number Rather Than Name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135682#M36668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello SAS Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know a way to call a variable based on the column location rather than the column name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to pass data sets to a macro procedure and run FREQ on the first 2 columns of the data set, however the names of these variables will vary. So my question is if I can identify the variables in the FREQ procedure without knowing the variable names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FREQ DATA =T1;&lt;/P&gt;&lt;P&gt;TABLE &lt;STRONG&gt;ColVar1&lt;/STRONG&gt; /OUT =T2;&lt;/P&gt;&lt;P&gt;TABLE &lt;STRONG&gt;ColVar2&lt;/STRONG&gt; /OUT =T3;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 18:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135682#M36668</guid>
      <dc:creator>mikemangini</dc:creator>
      <dc:date>2014-10-21T18:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select Variables by Column Number Rather Than Name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135683#M36669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This?&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; freqbynum(data=,num=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; varlist;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; proc transpose data=&amp;amp;data(obs=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) out=varnames;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var _all_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; proc sql noprint;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select _name_ into :varlist separated by &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from varnames(obs=&amp;amp;num);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; proc freq data=&amp;amp;data;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tables &amp;amp;varlist;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%mend&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;%&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #000000; background-color: #ffffff;"&gt;freqbynum&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(data=sashelp.heart);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 18:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135683#M36669</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-10-21T18:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select Variables by Column Number Rather Than Name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135684#M36670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This almost does what I was hoping perfectly. One last step though is that I would like to put the output from each variable out into its own table. Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;TABLE &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;ColVar1&lt;/STRONG&gt; /OUT =T2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;TABLE &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;ColVar2&lt;/STRONG&gt; /OUT =T3;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 19:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135684#M36670</guid>
      <dc:creator>mikemangini</dc:creator>
      <dc:date>2014-10-21T19:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Select Variables by Column Number Rather Than Name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135685#M36671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You would be better off with one data set of all the variables in one. ODS OUTPUT ONEWAYFREQS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; freqbynum(data=,num=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; varlist;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; proc transpose data=&amp;amp;data(obs=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) out=varnames;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var _all_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; proc sql noprint;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select catx(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'tables'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,_name_,cats(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'/ out=T'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,monotonic()),&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;';'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) into :varlist separated by &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from varnames(obs=&amp;amp;num);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; proc freq data=&amp;amp;data;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;varlist;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%mend&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;options&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;mprint&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;%&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #000000; background-color: #ffffff;"&gt;freqbynum&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(data=sashelp.heart);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 19:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135685#M36671</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-10-21T19:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select Variables by Column Number Rather Than Name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135686#M36672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much for your solution. I will try ODS. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 20:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135686#M36672</guid>
      <dc:creator>mikemangini</dc:creator>
      <dc:date>2014-10-21T20:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Select Variables by Column Number Rather Than Name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135687#M36673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;NULL , You can do it as simple as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
data _null_;
 dsid=open('sashelp.class','i');
 call symputx('first',varname(dsid,1));
 call symputx('second',varname(dsid,2));
run;
%put First is: &amp;amp;first | Second is: &amp;amp;second ;
proc freq data=sashelp.class;
table &amp;amp;first ;
table &amp;amp;second ;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 13:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-Variables-by-Column-Number-Rather-Than-Name/m-p/135687#M36673</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-22T13:21:17Z</dc:date>
    </item>
  </channel>
</rss>

