BookmarkSubscribeRSS Feed
EVN
Calcite | Level 5 EVN
Calcite | Level 5
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).
4 REPLIES 4
Patrick
Opal | Level 21
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
EVN
Calcite | Level 5 EVN
Calcite | Level 5
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
;
Cynthia_sas
Diamond | Level 26
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
Ksharp
Super User
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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3411 views
  • 0 likes
  • 4 in conversation