<?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: reading a variable list using INFILE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575577#M162839</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281932"&gt;@taupirho&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Well if I was to spit up a 100 line dataset into subsets of 10 lines each ,&lt;BR /&gt;then split a 1000 line data set into subsets of ten lines each. That would&lt;BR /&gt;give me different numbers of subsets would it not?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If I wanted to split a bunch of data sets into, roughly, the same number of records this is the approach I would take. My example uses 100 records each. If you want a different number of lines then replace all of the 100 values in the code below with your number. Irregular numbers may be possible but you would need a different variable for each set for managing the multiple both in the SQL and the data step do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table tableinfo as
   select libname, memname, nobs, ceil( nobs/100) as sets
   from dictionary.tables
   where libname='LIB' and memtype='DATA';
quit;

data _null_;   
   set tableinfo;
   file print;
   length str $ 200.;
   do i=1 to sets;
      newmemname=cats(memname,i);
      fobs= (i-1)*100+1;
      lobs = i*100;
      str = catx(' ','data', newmemname,';');
      put str;
      str = catx(' ','set', catx('.',libname,memname),'firstobs=',fobs,'obs=',lobs,';');
      put str;
      str='run;';
      put str;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;The proc sql gets the names of the data sets, the number of observations and calculates how many sets of 100 lines would be needed.&lt;/P&gt;
&lt;P&gt;The LIBNAME stored in the dictionary.columns&amp;nbsp; is upper case so consider that when putting your name in the code. You may be able to select desired set names to process but you haven't provided any rules so none suggested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not indicate whether the new data sets went to the same library or not. I would likely recommend a different library. In which case this line&lt;/P&gt;
&lt;PRE&gt;str = catx(' ','data', newmemname,';');&lt;/PRE&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;PRE&gt;str = catx(' ','data', catxI('.','newlib',newmemname,';');&lt;/PRE&gt;
&lt;P&gt;The example writes code to the results window that you could copy to the editor and run or save for later. The File statement could be modified to write to a SAS program file. Or use Call Execute(str); instead of Put str; to submit lines for execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CAVEATS: If you have long data set names adding digits could create invalid names longer than 32 characters. Up to you to manage that case. If you have data sets with millions of lines a split by a small value then you increase the chance of this happening.&lt;/P&gt;
&lt;P&gt;If you have data sets whose names end in digit already then you run a chance of creating duplicate names. If is possible you may want to consider using&lt;/P&gt;
&lt;PRE&gt;      newmemname=cats(memname,'_',i);
&lt;/PRE&gt;
&lt;P&gt;remember that each additional character is more likely to get to the 32 character name limit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jul 2019 20:25:33 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-07-22T20:25:33Z</dc:date>
    <item>
      <title>reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575327#M162720</link>
      <description>&lt;P&gt;I currently use the following code to read a list of variable names&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data list_of_tables ;
infile datalines;
input TABLE_NAME &amp;amp; $40.;
datalines;
TABLE_1
TABLE_2
;
run;&lt;/PRE&gt;&lt;P&gt;Lets say I had a variable number of TABLE_N's to read in like this ie in one run&amp;nbsp; it would be 3, the next run it might be 5 etc ... . Is there a way to do this?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 11:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575327#M162720</guid>
      <dc:creator>taupirho</dc:creator>
      <dc:date>2019-07-22T11:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575337#M162725</link>
      <description>&lt;P&gt;I feel like I'm missing the point of your question. If you want to read in five table names, you would use this code. So what am I not understanding?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data list_of_tables ;
infile datalines;
input TABLE_NAME &amp;amp; $40.;
datalines;
TABLE_1
TABLE_2
TABLE_3
TABLE_4
TABLE_5
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jul 2019 12:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575337#M162725</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-22T12:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575341#M162727</link>
      <description>&lt;P&gt;Let's say I had&amp;nbsp; large datasets that I wanted to divide up into smaller datasets and then process each new sub-set of data. On one run the sub-division might give me 3 sub-sets, TABLE_1, TABLE_2, TABLE_3 . On another run it might give me&amp;nbsp;100 sub-sets, TABLE_1-100 &amp;nbsp;etc ...&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 12:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575341#M162727</guid>
      <dc:creator>taupirho</dc:creator>
      <dc:date>2019-07-22T12:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575345#M162729</link>
      <description>&lt;P&gt;Are you trying to say that this is part of some larger activity, where sometimes there are 100 datasets and sometimes there are 600 datasets and sometimes there are 7 dataset, and you want this splitting to happen automatically? How would you know how many datasets there are? What are the rules to do the splitting?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 12:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575345#M162729</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-22T12:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575350#M162730</link>
      <description>&lt;P&gt;Something like that. There are multiple datasets as input. Each input dataset is to be split up depending on&amp;nbsp;its size.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input dataset1 might&amp;nbsp;end up being split up into 5 sub datasets, input dataset2 might be split up into 10 sub-datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the end of each input dataset splitting I'll know how many sub-sets it was split into. How do I then cycle through&amp;nbsp;and get the name of each sub-set into a variable that I can use&amp;nbsp;to process it.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 12:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575350#M162730</guid>
      <dc:creator>taupirho</dc:creator>
      <dc:date>2019-07-22T12:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575353#M162732</link>
      <description>&lt;P&gt;And why do you have to split the dataset at all?&lt;/P&gt;
&lt;P&gt;Splitting datasets requires additional code for splitting, even more code to process the fragments and another amount of code to add everything together at the end.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 12:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575353#M162732</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-22T12:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575355#M162733</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281932"&gt;@taupirho&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Something like that. There are multiple datasets as input. Each input dataset is to be split up depending on&amp;nbsp;its size.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input dataset1 might&amp;nbsp;end up being split up into 5 sub datasets, input dataset2 might be split up into 10 sub-datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the end of each input dataset splitting I'll know how many sub-sets it was split into. How do I then cycle through&amp;nbsp;and get the name of each sub-set into a variable that I can use&amp;nbsp;to process it.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you know how many sub-sets it was split into, but how would any SAS code that we write know?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 12:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575355#M162733</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-22T12:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575357#M162735</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;And why do you have to split the dataset at all?&lt;/P&gt;
&lt;P&gt;Splitting datasets requires additional code for splitting, even more code to process the fragments and another amount of code to add everything together at the end.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I agree with this, usually you would not want to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The exception where you would want to do this is if you are parallelizing some very time consuming task, and you can run parts of this task on different remote computers simultaneously. So,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281932"&gt;@taupirho&lt;/a&gt;, are you in this situation, or not?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 13:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575357#M162735</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-22T13:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575369#M162740</link>
      <description>&lt;P&gt;We are doing some numerical and frequency analysis&amp;nbsp;a series of big datasets. A small data set would be 2.5 Gb and going up to 500Gb.&lt;/P&gt;&lt;P&gt;When I tried our analysis code on the one of the small datasets I got a memory error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table XYZ (Number 1) Frequency Analysis began at Runtime 10:36:48. Rundate 11/07/2019.&lt;BR /&gt;Table XYZ (Number 1) has 537 Fields for Frequency Analysis&lt;BR /&gt;ERROR: PROC SUMMARY was terminated prematurely due to a memory shortage. Adjusting MEMSIZE and/or SUMSIZE may allow normal&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; processing to complete.&lt;BR /&gt;ERROR: The SAS System stopped processing this step because of insufficient memory.&lt;BR /&gt;WARNING: The data set WORK.SUMM1 may be incomplete.&amp;nbsp; When this step was stopped there were 0 observations and 2 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So one thought is to split up the larger datasets into smaller ones and do the analysis on each of the sub-sets&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 13:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575369#M162740</guid>
      <dc:creator>taupirho</dc:creator>
      <dc:date>2019-07-22T13:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575375#M162741</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281932"&gt;@taupirho&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;We are doing some numerical and frequency analysis&amp;nbsp;a series of big datasets. A small data set would be 2.5 Gb and going up to 500Gb.&lt;/P&gt;
&lt;P&gt;When I tried our analysis code on the one of the small datasets I got a memory error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table XYZ (Number 1) Frequency Analysis began at Runtime 10:36:48. Rundate 11/07/2019.&lt;BR /&gt;Table XYZ (Number 1) has 537 Fields for Frequency Analysis&lt;BR /&gt;ERROR: PROC SUMMARY was terminated prematurely due to a memory shortage. Adjusting MEMSIZE and/or SUMSIZE may allow normal&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; processing to complete.&lt;BR /&gt;ERROR: The SAS System stopped processing this step because of insufficient memory.&lt;BR /&gt;WARNING: The data set WORK.SUMM1 may be incomplete.&amp;nbsp; When this step was stopped there were 0 observations and 2 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So one thought is to split up the larger datasets into smaller ones and do the analysis on each of the sub-sets&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I consider this to be a valid reason to split up the dataset, but you still need to explain how you know how many variables you have, and how they will be split.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PLEASE GIVE A REALISTIC EXAMPLE.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575375#M162741</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-22T14:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575413#M162757</link>
      <description>&lt;P&gt;If you want to supply a list of variable names that you can use in SAS code it might be easier to supply them in a macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let varlist=
 AGE
 HEIGHT
 WEIGHT
;
proc summary data=sashelp.class ;
 var &amp;amp;varlist;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If want to get a list of variables in an existing dataset then you can ask SAS to tell you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=have out=contents; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to put a list of names into a macro variable from a set of names in a dataset then you can use the INTO clause of SQL query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select name into :varlist separated by ' '
from contents;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 15:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575413#M162757</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T15:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575432#M162766</link>
      <description>&lt;P&gt;Can you create a variable list "on the fly". Something like (forgive the syntax as I'm a newbie)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let myvar=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do i 1 to 5;&lt;/P&gt;&lt;P&gt;myvar = myvar || "table_" &amp;amp;i.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let varlist = &amp;amp;myvar.;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 16:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575432#M162766</guid>
      <dc:creator>taupirho</dc:creator>
      <dc:date>2019-07-22T16:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575443#M162774</link>
      <description>&lt;P&gt;If you want a variable list where the names end in numbers then no need to list them all.&amp;nbsp; Just use a variable list in your code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=have;
  var table_1 - table_5 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jul 2019 16:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575443#M162774</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T16:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575450#M162781</link>
      <description>&lt;P&gt;If&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s reply doesn't quite answer your question, then please give a realistic example of the situation and what you expect.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 16:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575450#M162781</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-22T16:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575454#M162784</link>
      <description>&lt;P&gt;Ok, I want to split some datasets into a number of smaller sub-sets. The number of sub-sets will vary depending on the size of the input dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then want to set up a loop for each&amp;nbsp; sub-set and process it. I don't know in advance how many sub-sets there will be, only after the splitting has happened. In psuedocode,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Split dataset1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Produces&amp;nbsp; 5 sub-sets say&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;for i = 1 to 5&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;process subset_i&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Split dataset2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Produces&amp;nbsp; 100 sub-sets say&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;for x = 1 to 100&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;process subset_x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 16:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575454#M162784</guid>
      <dc:creator>taupirho</dc:creator>
      <dc:date>2019-07-22T16:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575457#M162787</link>
      <description>&lt;P&gt;So you can't tell us how one example winds up with 5 subsets and another example winds up with 100 subsets? There must be a process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you can query a library to find out how many data sets exist, and obtain their names. Is that what you need?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 16:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575457#M162787</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-22T16:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575460#M162790</link>
      <description>Well if I was to spit up a 100 line dataset into subsets of 10 lines each ,&lt;BR /&gt;then split a 1000 line data set into subsets of ten lines each. That would&lt;BR /&gt;give me different numbers of subsets would it not?&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Jul 2019 17:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575460#M162790</guid>
      <dc:creator>taupirho</dc:creator>
      <dc:date>2019-07-22T17:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575467#M162794</link>
      <description>&lt;P&gt;So, I'm not clear on your terminology, now that you bring up the 100 line dataset.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Exactly what are we talking about? Data sets? Variable names? Rows of a data set? Something else?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this has gone on long enough, I'm still not clear about what the problem is, we're not making progress; and I request you start from the beginning, explain the entire problem IN DETAIL with examples of what the inputs are to this desired SAS program, and what the outputs are. Please use the proper terminology as well.&amp;nbsp;Do not use "subset" as I don't know what that means in this context.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 17:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575467#M162794</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-22T17:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575577#M162839</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281932"&gt;@taupirho&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Well if I was to spit up a 100 line dataset into subsets of 10 lines each ,&lt;BR /&gt;then split a 1000 line data set into subsets of ten lines each. That would&lt;BR /&gt;give me different numbers of subsets would it not?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If I wanted to split a bunch of data sets into, roughly, the same number of records this is the approach I would take. My example uses 100 records each. If you want a different number of lines then replace all of the 100 values in the code below with your number. Irregular numbers may be possible but you would need a different variable for each set for managing the multiple both in the SQL and the data step do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table tableinfo as
   select libname, memname, nobs, ceil( nobs/100) as sets
   from dictionary.tables
   where libname='LIB' and memtype='DATA';
quit;

data _null_;   
   set tableinfo;
   file print;
   length str $ 200.;
   do i=1 to sets;
      newmemname=cats(memname,i);
      fobs= (i-1)*100+1;
      lobs = i*100;
      str = catx(' ','data', newmemname,';');
      put str;
      str = catx(' ','set', catx('.',libname,memname),'firstobs=',fobs,'obs=',lobs,';');
      put str;
      str='run;';
      put str;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;The proc sql gets the names of the data sets, the number of observations and calculates how many sets of 100 lines would be needed.&lt;/P&gt;
&lt;P&gt;The LIBNAME stored in the dictionary.columns&amp;nbsp; is upper case so consider that when putting your name in the code. You may be able to select desired set names to process but you haven't provided any rules so none suggested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not indicate whether the new data sets went to the same library or not. I would likely recommend a different library. In which case this line&lt;/P&gt;
&lt;PRE&gt;str = catx(' ','data', newmemname,';');&lt;/PRE&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;PRE&gt;str = catx(' ','data', catxI('.','newlib',newmemname,';');&lt;/PRE&gt;
&lt;P&gt;The example writes code to the results window that you could copy to the editor and run or save for later. The File statement could be modified to write to a SAS program file. Or use Call Execute(str); instead of Put str; to submit lines for execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CAVEATS: If you have long data set names adding digits could create invalid names longer than 32 characters. Up to you to manage that case. If you have data sets with millions of lines a split by a small value then you increase the chance of this happening.&lt;/P&gt;
&lt;P&gt;If you have data sets whose names end in digit already then you run a chance of creating duplicate names. If is possible you may want to consider using&lt;/P&gt;
&lt;PRE&gt;      newmemname=cats(memname,'_',i);
&lt;/PRE&gt;
&lt;P&gt;remember that each additional character is more likely to get to the 32 character name limit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 20:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575577#M162839</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-22T20:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: reading a variable list using INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575611#M162861</link>
      <description>&lt;P&gt;What code are you trying to run that is running out of memory?&amp;nbsp; Perhaps we can fix that code instead of worrying about splitting the data?&amp;nbsp; You might want to start a new thread explaining what analysis you are doing that needs so much memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you really have large datasets with hundreds of variables?&amp;nbsp; Are you sure that analyzing just some of the variables at a time will help?&amp;nbsp; Do you really need to split the data to do that?&amp;nbsp; Why not just pass a list of the variables to use to the analysis program?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you really have large datasets with so many observations?&amp;nbsp; Are you sure that analyzing just some of the observations at a time will help?&amp;nbsp; Do you really need to split the data to do that?&amp;nbsp; Why not just pass in a WHERE condition (or FIRSTOBS=/OBS= combination) to process just some of the observations?&amp;nbsp; Do you have a natural grouping variable (STATE, COUNTRY, STUDYID) that you could use to split the data into smaller parts?&amp;nbsp; Is the data already sorted by that variable(s)?&amp;nbsp; Could you just add BY group processing to your analysis to make it use less memory?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 22:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-a-variable-list-using-INFILE/m-p/575611#M162861</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T22:51:47Z</dc:date>
    </item>
  </channel>
</rss>

