<?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: split data into different sizes in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233610#M5790</link>
    <description>Kinda like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; said, but don't do this.&lt;BR /&gt;A data set with 84 variables is unlikely normalized. If you normalize you will get a robust structure that seldom needs to be changed. Also you minimize the maintenance of having variable specific code and avoiding the need for macro coding.</description>
    <pubDate>Sat, 07 Nov 2015 07:24:13 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2015-11-07T07:24:13Z</dc:date>
    <item>
      <title>split data into different sizes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233562#M5786</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am struggling in creating a macro to split a data into different sizes. For example, if I have 84 observations in my current data, and I want to split this into 4 datasets with sizes (10,20,30,24).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;For example, I have the following&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;data new;&lt;BR /&gt;do i =1 to 84;&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how do i get the following datasets?&lt;/P&gt;
&lt;P&gt;dataset1: i=1,2,3,4,5,6,7,8,9,10&lt;/P&gt;
&lt;P&gt;dataset2: i=11,12,13,14,15,16,17,18,19,20, ...... 30&lt;/P&gt;
&lt;P&gt;dataset3: i=31,32,33,34,..........................., 60&lt;/P&gt;
&lt;P&gt;dataset4: i=61,62,63,.......... 84&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;and then for each dataset I output the following: mean,sd, histogram&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;Im thinking of creating a macro since the number of datasets to create and the sizes will change for every different original data....&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;Thanks..&lt;/SPAN&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 21:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233562#M5786</guid>
      <dc:creator>statz</dc:creator>
      <dc:date>2015-11-06T21:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: split data into different sizes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233566#M5787</link>
      <description>&lt;P&gt;Most likely, the best advice would be this:&amp;nbsp; Don't do it!&amp;nbsp; Instead of splitting up the data, just add a new variable to your existing data set.&amp;nbsp; The new variable could be "1" for the first 10 observations, "2" for the next 20, "3" for the next 30, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can always process with a BY statement later to get statistics for each group, or possibly with a WHERE statement to select just a single group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll save a lot of headaches trying to come up with data set names and tracking which is which.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 21:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233566#M5787</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-11-06T21:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: split data into different sizes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233583#M5788</link>
      <description>&lt;P&gt;To follow&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;'s suggestion, you should do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
do i =1 to 84;
    output;
    end;
run;

%macro mySplit(dsn,sizes);
data split;
do s = &amp;amp;sizes.;
    set+1;
    do j = 1 to s;
        set &amp;amp;dsn;
        output;
        end;
    end;
drop s j;
run;

ods graphics / imagename="&amp;amp;dsn._graph";
proc univariate data=split;
by set;
var i;
histogram;
output out=out_&amp;amp;dsn. mean=mi std=stdi;
run;
%mend mySplit;

%mySplit(new,%str(10,20,30,24));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Nov 2015 22:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233583#M5788</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-11-06T22:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: split data into different sizes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233610#M5790</link>
      <description>Kinda like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; said, but don't do this.&lt;BR /&gt;A data set with 84 variables is unlikely normalized. If you normalize you will get a robust structure that seldom needs to be changed. Also you minimize the maintenance of having variable specific code and avoiding the need for macro coding.</description>
      <pubDate>Sat, 07 Nov 2015 07:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233610#M5790</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-11-07T07:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: split data into different sizes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233828#M5863</link>
      <description>&lt;P&gt;Thank you PG Stats! this is perfect! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2015 13:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233828#M5863</guid>
      <dc:creator>statz</dc:creator>
      <dc:date>2015-11-09T13:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: split data into different sizes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233829#M5864</link>
      <description>&lt;P&gt;Thanks... my main goal is to check if the data for each segment is normally distributed.... and in reality, I may have different number of observations. If the number of observations is small, then I might have only one &amp;nbsp;or 2 segments.... or when the data is large, i may have many&amp;nbsp;segments. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2015 13:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/split-data-into-different-sizes/m-p/233829#M5864</guid>
      <dc:creator>statz</dc:creator>
      <dc:date>2015-11-09T13:26:06Z</dc:date>
    </item>
  </channel>
</rss>

