<?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: splitting a table into many tables while retaining an id variable for each new table in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/298020#M8419</link>
    <description>It might be worth making each child dataset a SAS view. Especially if you plan to doing something immediately with the children.</description>
    <pubDate>Tue, 13 Sep 2016 13:14:49 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2016-09-13T13:14:49Z</dc:date>
    <item>
      <title>splitting a table into many tables while retaining an id variable for each new table</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/297890#M8413</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose that I have a data table consisting of 3 columns: id, name ,age.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 144pt;" border="0" width="192" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="3" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;id&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;name&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;age&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD&gt;john&lt;/TD&gt;
&lt;TD align="right"&gt;25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD&gt;suzy&lt;/TD&gt;
&lt;TD align="right"&gt;30&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I would like to do is to split this table into smaller tables consisting of the id and a variable, so is this case I will have 2 new tables:&lt;/P&gt;
&lt;P&gt;one table will consist of id and name, and the other will consist of the id and age:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="2" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;id&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;name&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD&gt;john&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD&gt;suzy&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="2" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;id&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;age&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;30&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For simplicity in this example I have only 3 variables, but it will be really helpful if I could have a code that will dynamically do this for any number of variables. Tried to think about how to do it but can't figure out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 02:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/297890#M8413</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-09-13T02:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: splitting a table into many tables while retaining an id variable for each new table</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/297905#M8414</link>
      <description>&lt;PRE&gt;

%let dsn=sashelp.class;
%let id=name;

proc transpose data=&amp;amp;dsn(drop=&amp;amp;id) out=temp;
 var _all_;
run;
data _null_;
 set temp;
 call execute(cat("data ",_name_,";set &amp;amp;dsn;keep &amp;amp;id ",_name_,";run;"));
run;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Sep 2016 04:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/297905#M8414</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-13T04:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: splitting a table into many tables while retaining an id variable for each new table</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/297906#M8415</link>
      <description>&lt;P&gt;Thank Ksharp!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 04:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/297906#M8415</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-09-13T04:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: splitting a table into many tables while retaining an id variable for each new table</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/298016#M8417</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;This should be faster because it all runs in one address space, but who knows all the details og&lt;BR /&gt;the dosubl architechure.&lt;BR /&gt;&lt;BR /&gt;data have;
input id name $ age;
cards4;
id name age
1 john 25
2 suzy 30
;;;;
run;quit;

data _null_;
   do name='name','age';
     call symputx('nam',name);
     rc=dosubl(resolve('
        data &amp;amp;nam;
           set have(keep=id &amp;amp;nam);
        run;quit;
     '));
   end;
run;quit;


146   data _null_;
147      do name='name','age';
148        call symputx('nam',name);
149        rc=dosubl(resolve('
150           data &amp;amp;nam;
151              set have(keep=id &amp;amp;nam);
152           run;quit;
153        '));
154      end;
155   run;

SYMBOLGEN:  Macro variable NAM resolves to name
SYMBOLGEN:  Macro variable NAM resolves to name
NOTE: There were 3 observations read from the data set WORK.HAVE.
NOTE: The data set WORK.NAME has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              1031.71k
      OS Memory           13792.00k
      Timestamp           09/13/2016 06:04:42 AM
      Step Count                        31  Switch Count  0


SYMBOLGEN:  Macro variable NAM resolves to age
SYMBOLGEN:  Macro variable NAM resolves to age
NOTE: There were 3 observations read from the data set WORK.HAVE.
NOTE: The data set WORK.AGE has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds                            Win 7 32bit SAS 9.3
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds                           Download and install 9.06 Ghostscipt
      memory              1031.71k
      OS Memory           13792.00k                              Scan the download
      Timestamp           09/13/2016 06:04:42 AM



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Sep 2016 13:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/298016#M8417</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2016-09-13T13:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: splitting a table into many tables while retaining an id variable for each new table</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/298018#M8418</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;This should be faster because it all runs in one address space, but who knows all the details of&lt;BR /&gt;the dosubl architechure.&lt;BR /&gt;&lt;BR /&gt;data have;
input id name $ age;
cards4;
id name age
1 john 25
2 suzy 30
;;;;
run;quit;

data _null_;
   do name='name','age';
     call symputx('nam',name);
     rc=dosubl(resolve('
        data &amp;amp;nam;
           set have(keep=id &amp;amp;nam);
        run;quit;
     '));
   end;
run;quit;



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Sep 2016 13:09:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/298018#M8418</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2016-09-13T13:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: splitting a table into many tables while retaining an id variable for each new table</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/298020#M8419</link>
      <description>It might be worth making each child dataset a SAS view. Especially if you plan to doing something immediately with the children.</description>
      <pubDate>Tue, 13 Sep 2016 13:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/splitting-a-table-into-many-tables-while-retaining-an-id/m-p/298020#M8419</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2016-09-13T13:14:49Z</dc:date>
    </item>
  </channel>
</rss>

