<?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: Referencing SAS Columns by location not variable name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142405#M28549</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't say what you are going to do with a loop but you would likely want to make sure that the variables are the same type for many operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something else to look at might be the Open, Varnum and Varname functions for reading details about datasets but I would likely start with the Dictionary tables i.e. Reeza's sashelp.vcolumns&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 May 2014 19:52:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-05-02T19:52:19Z</dc:date>
    <item>
      <title>Referencing SAS Columns by location not variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142402#M28546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to reference a column by position rather then its variable name.&amp;nbsp; I have multiple variables that have different names but i want to loop through them.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I have searched quite a bit for this but must be using the wrong terminology because i cant seem to get close to the answer I am looking for.&amp;nbsp; Is my only option to create an array and&lt;/P&gt;&lt;P&gt;name out all the variables and then step through the array?&amp;nbsp; Or is there a way to just pick variables 5 - 15 and loop through them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 16:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142402#M28546</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2014-05-02T16:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing SAS Columns by location not variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142403#M28547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need to list them out in an array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If its a one-off then that's the easiest. If its done multiple times, you could query sashelp.vcolumns and create a macro variable out of the names to feed an array but that seems like more work to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on what you're doing IML may also be an option.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 16:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142403#M28547</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-05-02T16:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing SAS Columns by location not variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142404#M28548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It might worth the trouble creating a macro if you have a lot of files.&lt;/P&gt;&lt;P&gt;Sample code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dsn=sashelp.class;&lt;/P&gt;&lt;P&gt;proc contents data=&amp;amp;dsn noprint out=test(keep=name varnum);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test(where=(varnum in(3,5)));;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symputx(cats('var',varnum),name);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set &amp;amp;dsn;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array _abc(*) &amp;amp;var3--&amp;amp;var5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array _new(*) new3-new5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do _n_=1 to dim(_abc);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _new(_n_)=_abc(_n_)*100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 19:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142404#M28548</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2014-05-02T19:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing SAS Columns by location not variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142405#M28549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't say what you are going to do with a loop but you would likely want to make sure that the variables are the same type for many operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something else to look at might be the Open, Varnum and Varname functions for reading details about datasets but I would likely start with the Dictionary tables i.e. Reeza's sashelp.vcolumns&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 19:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Referencing-SAS-Columns-by-location-not-variable-name/m-p/142405#M28549</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-02T19:52:19Z</dc:date>
    </item>
  </channel>
</rss>

