SAS_learner
SAS_learner

Reputation: 521

proc contents is truncating the values in out put dataset.How to get full values in out put dataset?

I'm trying to get all dataset names in a library in to a data set.

proc datasets library=LIB1 memtype=data ;
contents data=_all_ noprint  out=Datasets_in_Lib1(keep=memname) ;
run;

The final data set (Datasets_in_Lib1) is having all the data set names that are in LIB1, but names are truncated to 6 characters.Is there any way to get full names of the datasets with out truncation. Ex: If dataset name is x123456789, the Datasets_in_Lib1 will have x12345 only.

Thanks in advance, Sam.

Upvotes: 0

Views: 437

Answers (2)

Reeza
Reeza

Reputation: 21264

You can also query the sashelp.vtable to obtain the list of datasets:

proc sql;
create table mem_list as
select memname 
from sashelp.vtable
where libname='LIB1' and memtype='DATA';
quit;

Upvotes: 0

Quentin
Quentin

Reputation: 6378

Agree with the comment, in 9.3 memname is $32. I don't think there was a version of SAS where data set names were limited to 6 characters. They went from 8 characters to 32 characters in v7 (I think).

Here's a log from running your code, showing it works as you want in 9.3

51   data work.x123456789;
52   x=1;
53   run;

NOTE: The data set WORK.X123456789 has 1 observations and 1 variables.

54
55   proc datasets library=work memtype=data nolist;
56     contents data=_all_ noprint  out=Datasets_in_Lib1(keep=memname) ;
57   run;

NOTE: The data set WORK.DATASETS_IN_LIB1 has 1 observations and 1 variables.
58


59   data _null_;
60     set Datasets_in_Lib1;
61     put _all_;
62   run;

MEMNAME=X123456789 _ERROR_=0 _N_=1
NOTE: There were 1 observations read from the data set WORK.DATASETS_IN_LIB1.

Upvotes: 1

Related Questions