BookmarkSubscribeRSS Feed
Reeza
Super User

Curiousity question based on this post

 

Is there a way to get the metadata of a zipped SAS file without uncompressing it fully?

IIRC there's ways in R to process large SAS datasets essentially line by line so it can read only a few rows at a time so I'm wondering if something similar is possible in SAS directly or if the zipped/compression makes this impossible. 

 

Given this note in the blog post I don't think it's possible but curious. 

https://blogs.sas.com/content/sasdummy/2017/10/10/reading-writing-gzip-files-sas/

 

If your file is in a binary format such as a SAS data set (sas7bdat) or Excel (XLS or XLSX), you probably will need to expand the file completely before reading it as data. These files are read using special drivers that don't process the bytes sequentially, so you need the entire file available on disk.

1 REPLY 1
Tom
Super User Tom
Super User

No.  Just as the quotes says.  The SAS7BDAT file is a binary file.   You have to have the actual file for SAS to read it.

 

When I tried making a copy of a dataset that only included the beginning the resulting file is unusable by SAS.

228    set sashelp.class;
229  run;

NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


230  options generic;
231
232  data _null_;
233    infile "%sysfunc(pathname(work))/class.sas7bdat" lrecl=512 recfm=f obs=10;
234    file "%sysfunc(pathname(work))/class2.sas7bdat" lrecl=512 recfm=f ;
235    input;
236    put _infile_;
237  run;

NOTE: The infile "(system-specific pathname)/class.sas7bdat" is:
      (system-specific pathname),
      (system-specific file attributes)

NOTE: The file "(system-specific pathname)/class2.sas7bdat" is:
      (system-specific pathname),
      (system-specific file attributes)

NOTE: 10 records were read from the infile (system-specific pathname).
NOTE: 10 records were written to the file (system-specific pathname).
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


238
239
240  proc contents data=class2;
ERROR: Attempt to reference a page past end-of-file on WORK.CLASS2.DATA.
241  run;

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

NOTE: The SAS System stopped processing this step because of errors.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 201 views
  • 0 likes
  • 2 in conversation