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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.