<?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: selecting a range of columns in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233123#M42550</link>
    <description>&lt;P&gt;Sure, you can use SAS variable lists to refer to a list of variable names, as long as they are similarly named, e.g. var1:var255&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000695105.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000695105.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Nov 2015 17:49:00 GMT</pubDate>
    <dc:creator>MaikH_Schutze</dc:creator>
    <dc:date>2015-11-04T17:49:00Z</dc:date>
    <item>
      <title>selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233121#M42548</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello everyone, I have a data set with about 900 columns in it. I want to export this data set into access, since&amp;nbsp;access cannot handle more than 255 variables, I want to split the data set into four data sets with less than 255 columns. I was wondering is there a way to select a range of columns in sas? Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2015 17:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233121#M42548</guid>
      <dc:creator>Sepehrp</dc:creator>
      <dc:date>2015-11-04T17:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233122#M42549</link>
      <description>Please don't post the same question in multiple forums.  &lt;BR /&gt;&lt;BR /&gt;You can look at the Dictionary tables, the sashelp.vcolumn for your dataset and pick up the variables required. Here's a sample, untested.&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select nameinto :var_list1 separated by " "&lt;BR /&gt;where libname="MYLIB" and memname='MYDATA'&lt;BR /&gt;and varnum between 1 and 255;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;data want1;&lt;BR /&gt;set have1 (keep = &amp;amp;var_list1);&lt;BR /&gt;run;</description>
      <pubDate>Wed, 04 Nov 2015 17:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233122#M42549</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-04T17:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233123#M42550</link>
      <description>&lt;P&gt;Sure, you can use SAS variable lists to refer to a list of variable names, as long as they are similarly named, e.g. var1:var255&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000695105.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000695105.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2015 17:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233123#M42550</guid>
      <dc:creator>MaikH_Schutze</dc:creator>
      <dc:date>2015-11-04T17:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233125#M42552</link>
      <description>&lt;P&gt;You can use variable lists. If the variables have names that are related and start with the same string of characters then use: CommonText: and would select all of the variables that start with that text. You can also use a - to indicate a range of variables suchas Avarname - ThatVarname. Use the list(s) in a keep statement. Recommend that you have any identification variables in each set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to experiment with the different form of lists to see how many you get.&lt;/P&gt;
&lt;P&gt;Example: Suppose a data set has variables named VarName1 to VarName100 such as 100 similar measurements and another 20 variables whose names start with Col the dataset want below would have 45 variables, the 25 sepecified with VarName and all 20 of the Col.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have (keep= VarName1 - VarName25 Col: )&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2015 17:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233125#M42552</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-11-04T17:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233148#M42556</link>
      <description>&lt;P&gt;Another approach (similar to Reeza's) is to use&amp;nbsp;ranges of variables according to their varnum (i.e. their internal variable number). As a preparation you would run a PROC CONTENTS on your dataset with the VARNUM option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=yourdata varnum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In section "Variables in Creation Order" of the resulting output you can see (in column with header "#") which variable is no. 1, which one is no. 254, which one is no. 255, no. 508 (=2*254), no. 509, no. 762 (=3*254), no. 763 and which one is last (say, no. 900).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can easily form the appropriate&amp;nbsp;ranges in KEEP= options of data steps like the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data part1;
set yourdata(keep=idvar numberone--twofivefour);
run;

data part2;
set yourdata(keep=idvar twofivefive--fivezeroeight);
run;

/* and so on */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, the funny names numberone, twofivefour etc. need to be replaced by the corresponding variable names (of no. 1, no. 254 etc.). Dataset PART1 will then contain the first 254 variables, PART2 the second block of 254, PART3 (not shown above) the third and PART4 the remaining ones (about 900-762=138), without any requirements on how your variables are actually named or what their types are. The disadvantage of this approach is that the variables will be grouped just as they happen to be arranged in your dataset, disregarding contents.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I strongly support &lt;STRONG&gt;ballardw&lt;/STRONG&gt;'s recommendation of keeping an additional (e.g. 255th if that is possible) variable in each of the datasets PART1 - PART4 as a common record identifier (named IDVAR in the example code above). Depending on your data, you may even need more than one record-identifying variable (in this case&amp;nbsp;reduce the number of variables in the ranges accordingly to less than 254).&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2015 19:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233148#M42556</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-04T19:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233221#M42578</link>
      <description>&lt;P&gt;Well, you have some good answers above. &amp;nbsp;I would like to take another vien however. &amp;nbsp;The question I would ask is Why do you have 900 columns? &amp;nbsp;If you move this data into an RDBMs strcuture you will find your work is multiplied endlessly. &amp;nbsp;RDBMs are strcutured to have long tables, with few variables, where duplication is eraditcated. &amp;nbsp;I would start by first learning this. &amp;nbsp;Next, once you understand Relational DataBase Model strcucture, then examine your data. &amp;nbsp;Look at normalising the data, ie. take a wide dataset, and make log dataset, for example:&lt;/P&gt;
&lt;P&gt;HAVE&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp;VAR1 &amp;nbsp;VAR2 &amp;nbsp; VAR3 ...&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp;abc &amp;nbsp; &amp;nbsp; def &amp;nbsp; &amp;nbsp; &amp;nbsp; efg&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WANT&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp; &amp;nbsp;VARNUM &amp;nbsp; &amp;nbsp;RESULT&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; def&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; efg&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have normalised your data, then start to identify where duplication appears and split this up into different tables:&lt;/P&gt;
&lt;P&gt;HAVE&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp; &amp;nbsp;COMPANY &amp;nbsp; &amp;nbsp;COMPANY_ADDRESS VARNUM &amp;nbsp; RESULT&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc road &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc road &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;def&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc road &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;efg&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WANT1&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp; COMPANY_ID &amp;nbsp;VARNUM &amp;nbsp; RESULT&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abc&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;def&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;efg&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;WANT2&lt;/P&gt;
&lt;P&gt;COMPANY_ID &amp;nbsp;COMPANY_ADDR&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc road&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you are doing is changing technologies, so you would want to change the way you think about your data. &amp;nbsp;In the above, the data is smaller, and can easily be merged, but also specifying columns and such like is far easier which will help you write SQL. &amp;nbsp;Also, as a word of recomendation, if you need a database, I would look at one of the free databases rather than Access. &amp;nbsp;Whilst Access is simple to start with a proper database will serve you better in the long run. &amp;nbsp;Depending on what you need there is SQLlite for embedded databases, MySQL etc.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 10:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233221#M42578</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-05T10:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233291#M42592</link>
      <description>Sorry about that, thank you</description>
      <pubDate>Thu, 05 Nov 2015 18:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233291#M42592</guid>
      <dc:creator>Sepehrp</dc:creator>
      <dc:date>2015-11-05T18:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233292#M42593</link>
      <description>Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 05 Nov 2015 18:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233292#M42593</guid>
      <dc:creator>Sepehrp</dc:creator>
      <dc:date>2015-11-05T18:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233293#M42594</link>
      <description>Thank you</description>
      <pubDate>Thu, 05 Nov 2015 18:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233293#M42594</guid>
      <dc:creator>Sepehrp</dc:creator>
      <dc:date>2015-11-05T18:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: selecting a range of columns in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233294#M42595</link>
      <description>Thank you, that was really helpful</description>
      <pubDate>Thu, 05 Nov 2015 18:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-a-range-of-columns-in-sas/m-p/233294#M42595</guid>
      <dc:creator>Sepehrp</dc:creator>
      <dc:date>2015-11-05T18:27:15Z</dc:date>
    </item>
  </channel>
</rss>

