<?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 splitting a data set into multiple data sets by using macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510228#M137320</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to ask a question about splitting a data set into multiple data sets by using macro.&lt;/P&gt;
&lt;P&gt;In the following example there are 4 unique values to variable deptdescirption.&lt;/P&gt;
&lt;P&gt;Why in the result there are 5 data sets?&lt;/P&gt;
&lt;P&gt;What is the mistake in code here?&lt;/P&gt;
&lt;P&gt;Why for value "Public Health" there are 2 data sets??&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;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input @1 deptid 1. deptdescription $ &amp;amp; 3-20;
datalines;
1 Maths
2 Astronomy
1 Maths
3 Physics
4 Public Health
3 Physics
;
run;

proc sort data=have;
by deptid;
run;

data _null_;
set have;
by deptid;
if first.deptid then do;
i+1;
call symputx('subj'|| left(put(i,2.)),deptdescription);
end;
if last.deptid then call symputx('total',i);
run;
%put &amp;amp;subj1;/*Maths*/
%put &amp;amp;subj2;/*Astronomy*/
%put &amp;amp;subj3;/*Physics*/
%put &amp;amp;subj4;/*Public Health*/
%put &amp;amp;total;/*4*/
 
%macro mmacro;
%do i=1 %to &amp;amp;total.;
data &amp;amp;&amp;amp;subj&amp;amp;i;
set have;
where deptdescription="&amp;amp;&amp;amp;subj&amp;amp;i";
run;
%end;
%mend mmacro;
%mmacro;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 04 Nov 2018 07:29:04 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2018-11-04T07:29:04Z</dc:date>
    <item>
      <title>split a data set into multiple data sets using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510229#M137318</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I &amp;nbsp;am trying to split a data set into multiple data sets.&lt;/P&gt;
&lt;P&gt;In this example I get 5 data sets but the variable contains only 4 unique values.&lt;/P&gt;
&lt;P&gt;What is the error in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input @1 deptid 1. deptdescription $ &amp;amp; 3-20;
datalines;
1 Maths
2 Astronomy
1 Maths
3 Physics
4 Public Health
3 Physics
;
run;
proc sort data=have;
by deptid;
run;
data _null_;
set have;
by deptid;
if first.deptid then do;
i+1;
call symputx('subj'|| left(put(i,2.)),deptdescription);
end;
if last.deptid then call symputx('total',i);
run;
%put &amp;amp;subj1;/*Maths*/
%put &amp;amp;subj2;/*Astronomy*/
%put &amp;amp;subj3;/*Physics*/
%put &amp;amp;subj4;/*Public Health*/
%put &amp;amp;total;/*4*/
 
%macro mmacro;
%do i=1 %to &amp;amp;total.;
data &amp;amp;&amp;amp;subj&amp;amp;i;
set have;
where deptdescription="&amp;amp;&amp;amp;subj&amp;amp;i";
run;
%end;
%mend mmacro;
%mmacro;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 07:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510229#M137318</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-11-04T07:36:53Z</dc:date>
    </item>
    <item>
      <title>splitting a data set into multiple data sets by using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510228#M137320</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to ask a question about splitting a data set into multiple data sets by using macro.&lt;/P&gt;
&lt;P&gt;In the following example there are 4 unique values to variable deptdescirption.&lt;/P&gt;
&lt;P&gt;Why in the result there are 5 data sets?&lt;/P&gt;
&lt;P&gt;What is the mistake in code here?&lt;/P&gt;
&lt;P&gt;Why for value "Public Health" there are 2 data sets??&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;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input @1 deptid 1. deptdescription $ &amp;amp; 3-20;
datalines;
1 Maths
2 Astronomy
1 Maths
3 Physics
4 Public Health
3 Physics
;
run;

proc sort data=have;
by deptid;
run;

data _null_;
set have;
by deptid;
if first.deptid then do;
i+1;
call symputx('subj'|| left(put(i,2.)),deptdescription);
end;
if last.deptid then call symputx('total',i);
run;
%put &amp;amp;subj1;/*Maths*/
%put &amp;amp;subj2;/*Astronomy*/
%put &amp;amp;subj3;/*Physics*/
%put &amp;amp;subj4;/*Public Health*/
%put &amp;amp;total;/*4*/
 
%macro mmacro;
%do i=1 %to &amp;amp;total.;
data &amp;amp;&amp;amp;subj&amp;amp;i;
set have;
where deptdescription="&amp;amp;&amp;amp;subj&amp;amp;i";
run;
%end;
%mend mmacro;
%mmacro;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 07:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510228#M137320</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-11-04T07:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: split a data set into multiple data sets using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510230#M137319</link>
      <description>&lt;P&gt;"Public Health" is not a valid SAS name.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 08:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510230#M137319</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-04T08:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: splitting a data set into multiple data sets by using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510252#M137324</link>
      <description>&lt;P&gt;those are all very good questions to ask.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Research and prior understanding of SAS tools you are requesting answers to would answer these basics questions like the space in the &lt;SPAN&gt;deptdescirption&lt;/SPAN&gt; for &lt;SPAN&gt;deptid&lt;/SPAN&gt; 4.&lt;/P&gt;
&lt;P&gt;Know your data, have a basic&amp;nbsp;understanding of the tools you are trying to use.&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>Sun, 04 Nov 2018 15:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-a-data-set-into-multiple-data-sets-using-macro/m-p/510252#M137324</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-04T15:31:51Z</dc:date>
    </item>
  </channel>
</rss>

