BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JohnChen_TW
Quartz | Level 8

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

 

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;

 

 

 

View solution in original post

6 REPLIES 6
thomp7050
Pyrite | Level 9
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

Reeza
Super User

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. 

thomp7050
Pyrite | Level 9

Thank you, Reeza.  You have added to my knowledge today.

JohnChen_TW
Quartz | Level 8

Thanks for your suggestion.

 

But I'd like to print the label on dataset (shown as below), not column label.

未命名.png

 

How to create another dataset to save "label on dataset as above", file size, created date, and observations?

 

JC

Reeza
Super User

 

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;

 

 

 

JohnChen_TW
Quartz | Level 8
Many thanks for your resolution.
I am not good at proc SQL, actually.

JC

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 933 views
  • 1 like
  • 3 in conversation