<?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: create 100+ datasets from one dataset by splitting a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26120#M4622</link>
    <description>Perhaps you can find inspiration in this answer&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=19230䬞" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=19230䬞&lt;/A&gt;&lt;BR /&gt;
or &lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=19559䱧" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=19559䱧&lt;/A&gt;</description>
    <pubDate>Fri, 01 May 2009 10:57:21 GMT</pubDate>
    <dc:creator>GertNissen</dc:creator>
    <dc:date>2009-05-01T10:57:21Z</dc:date>
    <item>
      <title>create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26118#M4620</link>
      <description>I have a dataset with 3 variables only and one variable is area name which has 100+ different areas.  Is there an easy way of splitting the dataset into 100+ datasets instead of stacks of code. &lt;BR /&gt;
I know how to do it using a macro but need to know how to create macro-variables from the area name variable attributes and loop into the macro rather than typing each one out.&lt;BR /&gt;
&lt;BR /&gt;
Your help will be much appreciated.&lt;BR /&gt;
Cheers</description>
      <pubDate>Fri, 01 May 2009 09:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26118#M4620</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-01T09:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26119#M4621</link>
      <description>You just need something along the lines of.........&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select count(area) into :maxarea&lt;BR /&gt;
    from tablename; /* I'm assuming distinct areas */&lt;BR /&gt;
&lt;BR /&gt;
 select area into :area1-:area%left&amp;amp;maxarea&lt;BR /&gt;
    from tablename; &lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
and voila, a list of macro variables (area1 thru area(n)) for you to loop through</description>
      <pubDate>Fri, 01 May 2009 10:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26119#M4621</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-01T10:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26120#M4622</link>
      <description>Perhaps you can find inspiration in this answer&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=19230䬞" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=19230䬞&lt;/A&gt;&lt;BR /&gt;
or &lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=19559䱧" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=19559䱧&lt;/A&gt;</description>
      <pubDate>Fri, 01 May 2009 10:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26120#M4622</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2009-05-01T10:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26121#M4623</link>
      <description>What are you trying to do?  I expect you can do without macro are at least without 100s of macro variables.</description>
      <pubDate>Fri, 01 May 2009 11:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26121#M4623</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-05-01T11:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26122#M4624</link>
      <description>try [PRE]   CLASS[/pre]and/or[pre]   BY[/pre] statement processing in your analytic procedures.&lt;BR /&gt;
 &lt;BR /&gt;
If that is not enough, please explain how you want to use these 100+ data sets.&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 05 May 2009 15:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26122#M4624</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-05-05T15:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26123#M4625</link>
      <description>Hi &lt;BR /&gt;
&lt;BR /&gt;
I'm creating these datasets to use in the SAS forecasting application at area level. &lt;BR /&gt;
&lt;BR /&gt;
The dataset has 130 areas and I need to split into individual area level datasets.  Unfortunately I've not used PROC SQL before so would appreciate any help in Base SAS language. &lt;BR /&gt;
&lt;BR /&gt;
Cheers</description>
      <pubDate>Wed, 06 May 2009 10:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26123#M4625</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-06T10:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26124#M4626</link>
      <description>surely the forecasting application supports by-processing and classing?&lt;BR /&gt;
&lt;BR /&gt;
You may find other forums more helpful.&lt;BR /&gt;
&lt;BR /&gt;
Although it is a xxxxxxxx to manage them, it is easy to create hundreds of data sets[pre] data rest %gen( pattern= data.area###, from=1, upto= 1000 ) ;&lt;BR /&gt;
   set original.data_set ;&lt;BR /&gt;
   select (area) ;&lt;BR /&gt;
     %gen( pattern= %str( when ( ### ) output data.area###  ; ) &lt;BR /&gt;
          , from=1, upto= 1000 )&lt;BR /&gt;
        otherwise output rest ;&lt;BR /&gt;
   end;&lt;BR /&gt;
run ;[/pre]&lt;BR /&gt;
That will split the table original.data_set into up to 1001 datasets assuming that rows with "area" having value, say 23, should be written into table data.area23 .&lt;BR /&gt;
Any rows with area outside the range 1-1000 will be written to table work.rest.&lt;BR /&gt;
The code assumes you have a macro %GEN() available that works by replacing ### in a pattern with a number varying from &amp;amp;from to &amp;amp;upto. Something like:[pre]%macro gen( from=1, upto= 10, pattern= asdf###asdfg )/ des='pattern generator';&lt;BR /&gt;
%local word pointer ;&lt;BR /&gt;
%do pointer = &amp;amp;from %to &amp;amp;upTo ;&lt;BR /&gt;
%sysfunc( tranwrd( %superq(pattern), ###, &amp;amp;pointer ))&lt;BR /&gt;
%end ;&lt;BR /&gt;
%mend  gen ;[/pre]&lt;BR /&gt;
but &lt;B&gt; beware code offered over the internet&lt;/B&gt; you might want to test it on less than &lt;I&gt;100&lt;/I&gt; datasets&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Wed, 06 May 2009 16:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26124#M4626</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-05-06T16:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26125#M4627</link>
      <description>Try this:&lt;BR /&gt;
%macro test;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	set yourdatasetname end = eof;----&amp;gt;give Your dataset name&lt;BR /&gt;
	if eof then call symput('obs',_n_);---&amp;gt;gives total number of observations&lt;BR /&gt;
	xvar = compress('dsn' || _n_);&lt;BR /&gt;
	call symput (xvar,fieldname);---give the field(area) you should provide&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%do i= 1 %to &amp;amp;obs;&lt;BR /&gt;
 %put &amp;amp;&amp;amp;dsn&amp;amp;i; ----&amp;gt;This part is to test if the macro &amp;amp;&amp;amp;dsn&amp;amp;i resolves to correct values!!&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend test;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro test1;&lt;BR /&gt;
&lt;BR /&gt;
%do i= 1 %to &amp;amp;obs;&lt;BR /&gt;
  data &amp;amp;&amp;amp;dsn&amp;amp;i;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-----Your sas logic------&lt;BR /&gt;
&lt;BR /&gt;
%end;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%mend test1;</description>
      <pubDate>Wed, 06 May 2009 19:33:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26125#M4627</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-05-06T19:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: create 100+ datasets from one dataset by splitting a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26126#M4628</link>
      <description>Thankyou very much for all your help guys - I've managed to get it to work with a combination of methods suggested. &lt;BR /&gt;
&lt;BR /&gt;
many thanks &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Thu, 07 May 2009 09:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-100-datasets-from-one-dataset-by-splitting-a-variable/m-p/26126#M4628</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-07T09:44:31Z</dc:date>
    </item>
  </channel>
</rss>

