<?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: Counting observations and subsetting into smaller datasets for Excel 97 exp in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-observations-and-subsetting-into-smaller-datasets-for/m-p/27033#M4857</link>
    <description>Rishi:&lt;BR /&gt;
&lt;BR /&gt;
The first step is to get the record count into a macro variable. The easiest way is an SQL statement.&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
  select count(*) into :nobs&lt;BR /&gt;
  from dsname;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Next step would be to determine the number of files to create:&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
  count=int(&amp;amp;nobs/65000) + 1;&lt;BR /&gt;
  call symputx('count',count);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Macro variable &amp;amp;count contains the number of tables to create. You can use this in a macro do loop.&lt;BR /&gt;
&lt;BR /&gt;
%macro xlcreate;&lt;BR /&gt;
  %do i=1 %to &amp;amp;count;&lt;BR /&gt;
    data temp;&lt;BR /&gt;
      set dsname;&lt;BR /&gt;
      obs=_n_;&lt;BR /&gt;
      if ((&amp;amp;i-1)*65000 + 1) le obs le &amp;amp;i*65000;&lt;BR /&gt;
    run;&lt;BR /&gt;
&lt;BR /&gt;
    /* use proc export, tagsets.excelxp or some other method to create an excel file, Use the &amp;amp;i macro variable to create file name versions */  &lt;BR /&gt;
    proc export data=temp ...&lt;BR /&gt;
  &lt;BR /&gt;
  %end;&lt;BR /&gt;
%mend;</description>
    <pubDate>Tue, 05 May 2009 02:45:57 GMT</pubDate>
    <dc:creator>barheat</dc:creator>
    <dc:date>2009-05-05T02:45:57Z</dc:date>
    <item>
      <title>Counting observations and subsetting into smaller datasets for Excel 97 exp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-observations-and-subsetting-into-smaller-datasets-for/m-p/27032#M4856</link>
      <description>I was wondering if anybody knows how to fix the following:&lt;BR /&gt;
&lt;BR /&gt;
I have a large datasets which updates every week so the total observation count is varying. Because I want to export to Excel 97 which can only handle 65,000 records I need to cut the SAS datasets into smaller pieces depending on the total observational count. &lt;BR /&gt;
&lt;BR /&gt;
For example if the SAS datasets contains 325,000 observations I would like SAS to create 325,000/65,000=5 subsets of the large datasets. &lt;BR /&gt;
&lt;BR /&gt;
Does anyone know how to do this?&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
&lt;BR /&gt;
Rishi</description>
      <pubDate>Mon, 04 May 2009 21:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-observations-and-subsetting-into-smaller-datasets-for/m-p/27032#M4856</guid>
      <dc:creator>43432</dc:creator>
      <dc:date>2009-05-04T21:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Counting observations and subsetting into smaller datasets for Excel 97 exp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-observations-and-subsetting-into-smaller-datasets-for/m-p/27033#M4857</link>
      <description>Rishi:&lt;BR /&gt;
&lt;BR /&gt;
The first step is to get the record count into a macro variable. The easiest way is an SQL statement.&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
  select count(*) into :nobs&lt;BR /&gt;
  from dsname;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Next step would be to determine the number of files to create:&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
  count=int(&amp;amp;nobs/65000) + 1;&lt;BR /&gt;
  call symputx('count',count);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Macro variable &amp;amp;count contains the number of tables to create. You can use this in a macro do loop.&lt;BR /&gt;
&lt;BR /&gt;
%macro xlcreate;&lt;BR /&gt;
  %do i=1 %to &amp;amp;count;&lt;BR /&gt;
    data temp;&lt;BR /&gt;
      set dsname;&lt;BR /&gt;
      obs=_n_;&lt;BR /&gt;
      if ((&amp;amp;i-1)*65000 + 1) le obs le &amp;amp;i*65000;&lt;BR /&gt;
    run;&lt;BR /&gt;
&lt;BR /&gt;
    /* use proc export, tagsets.excelxp or some other method to create an excel file, Use the &amp;amp;i macro variable to create file name versions */  &lt;BR /&gt;
    proc export data=temp ...&lt;BR /&gt;
  &lt;BR /&gt;
  %end;&lt;BR /&gt;
%mend;</description>
      <pubDate>Tue, 05 May 2009 02:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-observations-and-subsetting-into-smaller-datasets-for/m-p/27033#M4857</guid>
      <dc:creator>barheat</dc:creator>
      <dc:date>2009-05-05T02:45:57Z</dc:date>
    </item>
  </channel>
</rss>

