<?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: Divide population into macro variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766820#M243054</link>
    <description>&lt;P&gt;Macros not needed, this can be done in a data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cohorts;
    set population;
    cohort = floor((ids-1)/7500);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Sep 2021 11:47:34 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-09-09T11:47:34Z</dc:date>
    <item>
      <title>Divide population into macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766815#M243050</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to divide up a population into cohorts of subpopulations where I have the numbers in a macro var.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
&lt;BR /&gt;data Population;&lt;BR /&gt;do ids = 1 to 100000; &lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;;&lt;BR /&gt;run;

proc sql noprint;
            select ceil(count(*)/7500)
            into :cohort
            from Population;
      quit;
%put &amp;amp;cohort;

%macro test;
%do i = 1 %to &amp;amp;cohort;
  
            proc sql noprint;
                  select distinct ids
                  into :KSIds 
                  from Population(firstobs = &amp;amp;i cohort = &amp;amp;i);
            quit;
 %end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First I am finding out how many cohorts I need, then I am trying to get a macro to write&amp;nbsp; no more than 7500 KSids from the Population file into the KSIds0, KSIds1. KSids2 etc&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 11:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766815#M243050</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2021-09-09T11:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766820#M243054</link>
      <description>&lt;P&gt;Macros not needed, this can be done in a data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cohorts;
    set population;
    cohort = floor((ids-1)/7500);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Sep 2021 11:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766820#M243054</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-09T11:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766823#M243057</link>
      <description>&lt;P&gt;Or as a variant to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;proposes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Population;
  do ids = 1 to 100000; 
    output;
  end;
  stop;
run;

data cohorts;
  set population;
  cohort = mod(_n_,7500)+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Sep 2021 12:02:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766823#M243057</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-09-09T12:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766824#M243058</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I am misunderstood, (my poor explanation to blame)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the ids to be in a list&amp;nbsp;&lt;/P&gt;
&lt;P&gt;each macro containing ids&amp;nbsp;&lt;/P&gt;
&lt;P&gt;first cohort : id 1-7500&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;second cohort: id 7501-15000&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 12:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766824#M243058</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2021-09-09T12:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766829#M243062</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35213"&gt;@Kiteulf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I am misunderstood, (my poor explanation to blame)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the ids to be in a list&amp;nbsp;&lt;/P&gt;
&lt;P&gt;each macro containing ids&amp;nbsp;&lt;/P&gt;
&lt;P&gt;first cohort : id 1-7500&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;second cohort: id 7501-15000&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't know why you need them in a separate list, or actually many separate lists, when they are clearly identified in the data set I named COHORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What would you do with these macro variable lists once you have it? Please explain the next step. I'm relatively sure that the data set COHORT can provide what you need. Whatever the next step is, I don't think you need macro variables containing long lists of IDs.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 12:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-macro-variables/m-p/766829#M243062</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-09T12:28:54Z</dc:date>
    </item>
  </channel>
</rss>

