Hi everyone, I'm using SAS 9.3.
Does anyone have suggestions to retrieve "label", "size in byte", "observations (total rows)" and "created date" of a dataset, and also print it out?
Did you look at SAS.VTABLE? The field called memlabel holds the label. This works for my example below
data test (label='mydata');
set sashelp.class;
run;
PROC SQL;
CREATE TABLE info AS
SELECT *
FROM SASHELP.VTABLE
WHERE libname='WORK' and MEMNAME = 'TEST';
QUIT;
PROC SQL;
CREATE TABLE COLNAMES AS SELECT *
FROM DICTIONARY.COLUMNS
LEFT JOIN DICTIONARY.TABLES TABLES ON TABLES.MEMNAME = COLUMNS.MEMNAME
WHERE TABLES.MEMNAME = 'FLARM';
QUIT;
To get the total number of answers, you may want to create a looping macro to select count(case when col1 is not null then 1 else 0 end) for each of the variables, depending on their data type, and update your columns table.
Patrick
To add to @thomp7050 correct answer, use SASHELP.Vtable for information on a dataset and SASHELP.vcolumn for information on variables within a specific dataset. These are also known as dictionary.table and dictionary.column but you can't navigate to those, so I use the SASHELP convention to denote this.
Thank you, Reeza. You have added to my knowledge today.
Thanks for your suggestion.
But I'd like to print the label on dataset (shown as below), not column label.
How to create another dataset to save "label on dataset as above", file size, created date, and observations?
JC
Did you look at SAS.VTABLE? The field called memlabel holds the label. This works for my example below
data test (label='mydata');
set sashelp.class;
run;
PROC SQL;
CREATE TABLE info AS
SELECT *
FROM SASHELP.VTABLE
WHERE libname='WORK' and MEMNAME = 'TEST';
QUIT;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.