BookmarkSubscribeRSS Feed
43432
Calcite | Level 5
I was wondering if anybody knows how to fix the following:

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.

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.

Does anyone know how to do this?

Regards,

Rishi
1 REPLY 1
barheat
Fluorite | Level 6
Rishi:

The first step is to get the record count into a macro variable. The easiest way is an SQL statement.

proc sql noprint;
select count(*) into :nobs
from dsname;
quit;

Next step would be to determine the number of files to create:

data temp;
count=int(&nobs/65000) + 1;
call symputx('count',count);
run;

Macro variable &count contains the number of tables to create. You can use this in a macro do loop.

%macro xlcreate;
%do i=1 %to &count;
data temp;
set dsname;
obs=_n_;
if ((&i-1)*65000 + 1) le obs le &i*65000;
run;

/* use proc export, tagsets.excelxp or some other method to create an excel file, Use the &i macro variable to create file name versions */
proc export data=temp ...

%end;
%mend;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 608 views
  • 0 likes
  • 2 in conversation