<?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: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321 in Advanced Programming</title>
    <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969927#M341</link>
    <description>Hi Tom, I think this thread (your 2nd thread) is the best answer for my post (solves major problems regarding the codings in my post and my thinking and question in mind). PaigeMiller replied me first and offered a very good solution and possible improvement for my answer (and also the loop within a statement is a technique I just need to learn) and I marked as the answer.</description>
    <pubDate>Sat, 28 Jun 2025 17:16:29 GMT</pubDate>
    <dc:creator>dxiao2017</dc:creator>
    <dc:date>2025-06-28T17:16:29Z</dc:date>
    <item>
      <title>one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969768#M334</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;Have already had many posts on this topic about the split table macro solution regarding SAS SQL1 and Macro1 practice question. &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;This maybe the last one, s106s04,SAS SQL1,pdf p321, the solution (split table according to levels of one column) is as follows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_0-1750918048531.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108025iBACFF30FAA0A88ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_0-1750918048531.png" alt="dxiao2017_0-1750918048531.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I think the simpler solution is as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro split;
proc sql;
select distinct region
   into :reglist1-
   from sq.globalmetadata;
quit;
%do i=1 %to &amp;amp;sqlobs;
data gm&amp;amp;i;
   set sq.globalmetadata;
   where region="&amp;amp;&amp;amp;reglist&amp;amp;i";
run;
proc print data=gm&amp;amp;i(obs=2);
run;
%end;
%mend split;
%split;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_1-1750918284230.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108026iE4A14FB2D5D4AFA8/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_1-1750918284230.png" alt="dxiao2017_1-1750918284230.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_3-1750918351133.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108028i452D6DA9AB5F30A4/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_3-1750918351133.png" alt="dxiao2017_3-1750918351133.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dxiao2017_5-1750918411569.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108030iACF9D58870F00EC1/image-size/large?v=v2&amp;amp;px=999" role="button" title="dxiao2017_5-1750918411569.png" alt="dxiao2017_5-1750918411569.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 06:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969768#M334</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-06-26T06:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969780#M335</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro split;
proc sql noprint;
   select distinct region
   into :reglist1-
   from sq.globalmetadata;
quit;

data %do i=1 %to &amp;amp;sqlobs; gm&amp;amp;i %end; ;
   set sq.globalmetadata;
   %do i=1 %to &amp;amp;sqlobs; if region="&amp;amp;&amp;amp;reglist&amp;amp;i" then output gm&amp;amp;i%str(;) %end;
run;
%mend;
%split&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your data steps pass through the data &amp;amp;sqlobs times. In my code, the data step passes through the data once. Thus, my code will be faster, particularly if your real world data is huge. So I don't like splitting the data up using many data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code and my code also creates data sets whose names are gm1 gm2 ... and it may be hard to identify which data set to use when you are looking for "Latin America &amp;amp; Caribbean" data. So I don't like splitting the data up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I realize that this is an assignment of some sort, but in almost all cases, leaving the data in one big data set and then using BY statements seems to be a preferable way to go, rather than macro writing to create many smaller data sets (yes, there may be occasional exceptions to this rule). Reason number three why I don't like splitting the data up.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 12:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969780#M335</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-06-26T12:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969873#M336</link>
      <description>I think you are right. I'll use this technique when need to split dataset. The syntax is a bit more complex comparing to mine (and I was not familiar with a loop within a statement and I once put extra semicolon and also put the semicolon in wrong place). Thanks a lot for reply me!</description>
      <pubDate>Fri, 27 Jun 2025 16:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969873#M336</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-06-27T16:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969880#M337</link>
      <description>&lt;P&gt;The %MACRO is doing nothing in the example code in your photograph.&amp;nbsp; Once you have the set of commands in the macro variable ALLSTEPS you can just expand it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;allsteps;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There is not need to first wrap it into a macro defintion and then call the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you did want to define a macro it should probable include the SQL step and take as input parameters the source dataset and variable names (what for some reason it is calling table and column).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jun 2025 17:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969880#M337</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-27T17:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969881#M338</link>
      <description>&lt;P&gt;There are at least three problems with that approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code being generated into the macro variable ALLSTEPS might exceed the limit of 64K bytes that a single macro variable can hold.&amp;nbsp; And cutting that down to only 500 bytes&amp;nbsp; by using the LENGTH= option makes that even more likely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The values of the variable named in the COLUMN macro variable might not contain values that can be used to name the new datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And finally as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;showed it is making multiple passes through the source datasets to generate the target datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To solve the second problem you could use numeric suffixes for the new dataset names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general I find it much easier to use a data step to write code. Then you can take advantage of the power of the data step and especially the power of the PUT statement to generate the desired code.&amp;nbsp; And you can even make the code human readable by adding indentations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jun 2025 17:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969881#M338</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-27T17:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969925#M339</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, thanks for reply! The code in the screen capture consumes a lot of eyesight and also it was a bit too complex for me&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;, so I did not run and test it while learning the material. I did not follow that solution (the code in the screen capture) in the material and wrote my own answer (the code in the text box) to that practice question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you are right that, to resolve macro variable &lt;EM&gt;&amp;amp;allsteps&lt;/EM&gt;, the &lt;EM&gt;%runSteps&lt;/EM&gt; macro was not necessary, just use &lt;EM&gt;%put &amp;amp;allsteps;&lt;/EM&gt; (or the &lt;EM&gt;%put&lt;/EM&gt; is also unnecessary maybe) and one can solve it. And after reading your reply, I look at the code (in the screen capture) again, I can see that the code was intended to &lt;EM&gt;generate the code for a repeated data step through the proc sql step&lt;/EM&gt;. Perhaps it is a technique worth learning , in case of some unusual and rare scenarios (I hope not&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;) you just need to use sql to generate character strings for a data step.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jun 2025 16:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969925#M339</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-06-28T16:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969926#M340</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, thanks for this further explain! So using sql to generate code for data step's character string is &lt;EM&gt;totally(or absolutely) unstable and unreliable&lt;/EM&gt; approach. In any case when I can use data step, never try that approach. In simpler words, &lt;EM&gt;when I need to write data step's code, I just write data step, do not write other steps such as proc sql or marcos&lt;/EM&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jun 2025 17:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969926#M340</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-06-28T17:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969927#M341</link>
      <description>Hi Tom, I think this thread (your 2nd thread) is the best answer for my post (solves major problems regarding the codings in my post and my thinking and question in mind). PaigeMiller replied me first and offered a very good solution and possible improvement for my answer (and also the loop within a statement is a technique I just need to learn) and I marked as the answer.</description>
      <pubDate>Sat, 28 Jun 2025 17:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969927#M341</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-06-28T17:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969932#M342</link>
      <description>&lt;P&gt;To provide some perspective:&lt;/P&gt;
&lt;P&gt;In my professional career spanning more than two decades of SAS work, I did a split like this exactly once.&lt;/P&gt;
&lt;P&gt;The reason was this:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the batch job program needed to be frequently adapted by data warehouse end users&lt;/LI&gt;
&lt;LI&gt;DWH users had limits on storage which were not applied to the the batch job user&lt;/LI&gt;
&lt;LI&gt;a dataset reached a size during processing where the utility file of PROC SORT (or SQL) would crack the quota on the UTILLOC location&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So I split the dataset along the primary sort key, sorted each sub-dataset on the secondary keys, and created a view combining all sub-datasets.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Jun 2025 08:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969932#M342</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-06-29T08:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969957#M343</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466238"&gt;@dxiao2017&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, thanks for this further explain! So using sql to generate code for data step's character string is &lt;EM&gt;totally(or absolutely) unstable and unreliable&lt;/EM&gt; approach. In any case when I can use data step, never try that approach. In simpler words, &lt;EM&gt;when I need to write data step's code, I just write data step, do not write other steps such as proc sql or marcos [sic]&amp;nbsp;&lt;/EM&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm not sure Tom said anything about it being unstable and unreliable, although your limit of 500 characters may be a problem on larger real world data sets. Your code is neither unstable or unreliable for this problem, it is simply inefficient. There's also nothing wrong with using SQL or macros in the right situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to be ignoring the comments by myself and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;that there is rarely a reason to split data up like this. The first programming task in this situation is to determine in your mind if BY statements can handle the work better than separate data sets.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 11:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969957#M343</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-06-30T11:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969993#M344</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, thanks a lot for reply and your comments! Although I do not quiet understand what you said, I appreciate&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 17:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969993#M344</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-06-30T17:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969995#M345</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, thanks a lot for your comments!&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt; Although I do not quiet understand what you mean&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 17:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/969995#M345</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-06-30T17:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/970003#M346</link>
      <description>&lt;P&gt;There is rarely a need to split data sets like this. I know this is an assignment you have to work on, but some day you are going to be in the real world and there will be a problem just like this, and what I am saying (and I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;is saying) is that you shouldn't split the data set. Why? Because (except for rare cases) the BY statement does exactly what this macro splitting the data sets does and then some; also the BY statement works in most PROCs, so you can perform the task separately for each category (in your data set, the category was REGION) without splitting the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example of not splitting the data set and making use of the BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;
    by origin;
run;

proc freq data=cars;
    by origin;
    table type drivetrain make;
run;

proc means data=cars;
    by origin;
    var msrp invoice horsepower weight wheelbase length;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the same analysis, if you have to split the data and you don't use the BY statement. Please examine the code above and the code below and determine which code is shorter and easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro split;
proc sql noprint;
   select distinct origin
   into :origlist1-
   from sashelp.cars;
quit;

data %do i=1 %to &amp;amp;sqlobs; gm&amp;amp;i %end; ;
   set sashelp.cars;
   %do i=1 %to &amp;amp;sqlobs; if origin="&amp;amp;&amp;amp;origlist&amp;amp;i" then output gm&amp;amp;i%str(;) %end;
run;
%mend;
%split

proc freq data=gm1;
    table type drivetrain make;
run;

proc freq data=gm2;
    table type drivetrain make;
run;

proc freq data=gm3;
    table type drivetrain make;
run;

proc means data=gm1;
    var msrp invoice horsepower weight wheelbase length;
run;

proc means data=gm2;
    var msrp invoice horsepower weight wheelbase length;
run;

proc means data=gm3;
    var msrp invoice horsepower weight wheelbase length;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, the person who designed your assignment created an assignment that teaches the wrong lesson. After you finish the assignment, and you go out into the real world and you want to analyze data split by some category, a person who completed this assignment knows: "I can write a macro and split the data set". That is the wrong lesson. The right lesson to learn is that you can do this without splitting the data set (except for rare cases) by using the BY statement to split and analyze the data.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 18:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/970003#M346</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-06-30T18:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: one more and the last post about split table macro: s106s04, SAS SQL1:essential,pdf p321</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/970084#M347</link>
      <description>&lt;P&gt;Hi Paige, thanks a lot for reply, so in most cases, split table is not necessary, unless one really need to do so.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2025 08:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/one-more-and-the-last-post-about-split-table-macro-s106s04-SAS/m-p/970084#M347</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-07-02T08:18:25Z</dc:date>
    </item>
  </channel>
</rss>

