<?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: creat 3 dataset from 1 dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8110#M219</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
The powerful call execute routine can solve this issue:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
set in end=last;&lt;BR /&gt;
&lt;BR /&gt;
call symput ('mon',month);&lt;BR /&gt;
&lt;BR /&gt;
if _n_ eq 1 then call execute ('data jan feb mar;');&lt;BR /&gt;
&lt;BR /&gt;
call execute (cats('set in (obs=',_N_,' firstobs=',_N_,');' ));&lt;BR /&gt;
&lt;BR /&gt;
call execute ('output &amp;amp;mon;');&lt;BR /&gt;
&lt;BR /&gt;
if last then call execute('run;');&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
    <pubDate>Fri, 11 Feb 2011 18:10:34 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2011-02-11T18:10:34Z</dc:date>
    <item>
      <title>creat 3 dataset from 1 dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8106#M215</link>
      <description>I have a data set having below mention colum and data.&lt;BR /&gt;
&lt;BR /&gt;
month    pay         bonus&lt;BR /&gt;
jan        20000    1000&lt;BR /&gt;
jan        10000     1100&lt;BR /&gt;
jan         5000      2000&lt;BR /&gt;
feb        4000      3000&lt;BR /&gt;
feb        5000       4000&lt;BR /&gt;
mar        4800        600&lt;BR /&gt;
mar         5000       800&lt;BR /&gt;
&lt;BR /&gt;
I want to create 3 different data set jan feb mar like below &lt;BR /&gt;
&lt;BR /&gt;
        jan &lt;BR /&gt;
jan        20000    1000&lt;BR /&gt;
jan        10000     1100&lt;BR /&gt;
jan         5000      2000&lt;BR /&gt;
        feb&lt;BR /&gt;
feb        4000      3000&lt;BR /&gt;
feb        5000       4000&lt;BR /&gt;
        mar&lt;BR /&gt;
mar        4800        600&lt;BR /&gt;
mar         5000       800&lt;BR /&gt;
&lt;BR /&gt;
please help me</description>
      <pubDate>Fri, 11 Feb 2011 11:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8106#M215</guid>
      <dc:creator>arpit</dc:creator>
      <dc:date>2011-02-11T11:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: creat 3 dataset from 1 dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8107#M216</link>
      <description>With data grouped as in your example.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data all;&lt;BR /&gt;
   input month$ pay bonus;&lt;BR /&gt;
   cards;&lt;BR /&gt;
jan 20000 1000&lt;BR /&gt;
jan 10000 1100&lt;BR /&gt;
jan 5000 2000&lt;BR /&gt;
feb 4000 3000&lt;BR /&gt;
feb 5000 4000&lt;BR /&gt;
mar 4800 600&lt;BR /&gt;
mar 5000 800&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   set all;&lt;BR /&gt;
   by month notsorted;&lt;BR /&gt;
   if _n_ eq 1 then do;&lt;BR /&gt;
      declare hash d(ordered:'a');&lt;BR /&gt;
      d.definekey('_n_');&lt;BR /&gt;
      d.definedata('month','pay','bonus');&lt;BR /&gt;
      d.definedone();&lt;BR /&gt;
      end;&lt;BR /&gt;
   if first.month then d.clear();&lt;BR /&gt;
   d.add();&lt;BR /&gt;
   if last.month then d.output(dataset:month);&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 11 Feb 2011 12:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8107#M216</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-02-11T12:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: creat 3 dataset from 1 dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8108#M217</link>
      <description>If you need to generate a SAS file with unique/distinct values for a variable, consider using PROC SORT with NODUPKEY and a specific BY statement variable list.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 11 Feb 2011 16:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8108#M217</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-02-11T16:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: creat 3 dataset from 1 dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8109#M218</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
You could read about conditionally writing observations in more than one dataset at:&lt;BR /&gt;
  &lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001343763.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001343763.htm&lt;/A&gt;&lt;BR /&gt;
Warm regards,&lt;BR /&gt;
Vasile&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data database;&lt;BR /&gt;
   input month $3. pay bonus;&lt;BR /&gt;
   cards;&lt;BR /&gt;
jan 20000 1000&lt;BR /&gt;
jan 10000 1100&lt;BR /&gt;
jan 5000 2000&lt;BR /&gt;
feb 4000 3000&lt;BR /&gt;
feb 5000 4000&lt;BR /&gt;
mar 4800 600&lt;BR /&gt;
mar 5000 800&lt;BR /&gt;
;&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 data jan feb mar;&lt;BR /&gt;
 	set database;&lt;BR /&gt;
	select (month);&lt;BR /&gt;
		when ('jan') output jan;&lt;BR /&gt;
		when ('feb') output feb;&lt;BR /&gt;
		when ('mar') output mar;&lt;BR /&gt;
		otherwise;&lt;BR /&gt;
	 end;&lt;BR /&gt;
  run;</description>
      <pubDate>Fri, 11 Feb 2011 17:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8109#M218</guid>
      <dc:creator>Vasile01</dc:creator>
      <dc:date>2011-02-11T17:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: creat 3 dataset from 1 dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8110#M219</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
The powerful call execute routine can solve this issue:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
set in end=last;&lt;BR /&gt;
&lt;BR /&gt;
call symput ('mon',month);&lt;BR /&gt;
&lt;BR /&gt;
if _n_ eq 1 then call execute ('data jan feb mar;');&lt;BR /&gt;
&lt;BR /&gt;
call execute (cats('set in (obs=',_N_,' firstobs=',_N_,');' ));&lt;BR /&gt;
&lt;BR /&gt;
call execute ('output &amp;amp;mon;');&lt;BR /&gt;
&lt;BR /&gt;
if last then call execute('run;');&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
      <pubDate>Fri, 11 Feb 2011 18:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8110#M219</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-11T18:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: creat 3 dataset from 1 dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8111#M220</link>
      <description>[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
input month $ pay bonus;&lt;BR /&gt;
cards;&lt;BR /&gt;
jan 20000 1000&lt;BR /&gt;
jan 10000 1100&lt;BR /&gt;
jan 5000 2000&lt;BR /&gt;
feb 4000 3000&lt;BR /&gt;
feb 5000 4000&lt;BR /&gt;
mar 4800 600&lt;BR /&gt;
mar 5000 800&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 declare hash hh(ordered: 'a');&lt;BR /&gt;
 declare hiter ff('hh');&lt;BR /&gt;
 hh.definekey('month');&lt;BR /&gt;
 hh.definedata('month','_hh');&lt;BR /&gt;
 hh.definedone();&lt;BR /&gt;
 &lt;BR /&gt;
 declare hash _hh(ordered: 'a');&lt;BR /&gt;
 do until(last);&lt;BR /&gt;
  count+1;&lt;BR /&gt;
  set temp end=last;&lt;BR /&gt;
  rc=hh.find();&lt;BR /&gt;
  if rc ne 0 then do;&lt;BR /&gt;
                  _hh= _new_ hash(ordered: 'a');&lt;BR /&gt;
                  _hh.definekey('count');&lt;BR /&gt;
                  _hh.definedata('month','pay','bonus');&lt;BR /&gt;
                  _hh.definedone();&lt;BR /&gt;
                  hh.replace();&lt;BR /&gt;
                  end;&lt;BR /&gt;
  _hh.replace();&lt;BR /&gt;
 end;&lt;BR /&gt;
&lt;BR /&gt;
 rc=ff.first();&lt;BR /&gt;
 do while(rc =0);&lt;BR /&gt;
  _hh.output(dataset: month);&lt;BR /&gt;
  rc=ff.next();&lt;BR /&gt;
 end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 24 Feb 2011 01:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creat-3-dataset-from-1-dataset/m-p/8111#M220</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-02-24T01:08:19Z</dc:date>
    </item>
  </channel>
</rss>

