Help using Base SAS procedures

How to determine max record length in dataset

Reply
New Contributor EVN
New Contributor
Posts: 2

How to determine max record length in dataset

Hi! Is there a way to determine the maximum record length of a dataset?

I ask because I am running into an issue where I am exporting a dataset to MS Access 2003 and, with some of the records, the last few variables are dropping. I think it is due to the total record length being more than ~2000 characters for those records. I then have to remove some variables and execute the PROC EXPORT again (which works well after removing the variables).
Respected Advisor
Posts: 4,173

Re: How to determine max record length in dataset

Hi

Something like the (untested) code below might do.

proc sql;
select length(cats(of _all_)) as rec_length
from
having max(length(cats(of _all_))) = length(cats(of _all_))
/* having length(cats(of _all_)) > 2000 */
;
quit;

HTH
Patrick
New Contributor EVN
New Contributor
Posts: 2

Re: How to determine max record length in dataset

Admittedly, I'm a newby with SAS so I am not sure how to apply your code. Given the below example, how would I apply your code? I would anticipate the answer to be 16 (the longest record. Thanks!

data test;
input var1 var2 $5-17;
datalines;
123 abcdef
234 babcdefghij
3455 abcdefghijff
;
SAS Super FREQ
Posts: 8,868

Re: How to determine max record length in dataset

Hi:
That number will be the max length of the number of characters needed for a single observation, but do remember that when the data are stored in a SAS dataset, there is some overhead to how the dataset is organized because of the "header" information that SAS stores. This Tech Support note illustrates the complexity involved when trying to calculate the number of "pages" needed to store the data set on disk.
http://support.sas.com/kb/24/723.html

cynthia
Super User
Posts: 10,044

Re: How to determine max record length in dataset

I am not sure .The dictionary tables in PROC SQL have a variable
obslen num label='Observation Length' which you maybe need.But the record length i got is 24.

[pre]
proc sql feedback;
describe table dictionary.tables ;
quit;



data test;
input var1 var2 $5-17;
datalines;
123 abcdef
234 babcdefghij
3455 abcdefghijff
;
proc sql;
select memname,obslen
from dictionary.tables
where libname='WORK' and memname='TEST';
quit;
[/pre]



Ksharp Message was edited by: Ksharp
Ask a Question
Discussion stats
  • 4 replies
  • 302 views
  • 0 likes
  • 4 in conversation